JHtmlString::truncate() outputs invalid HTML

The support for Joomla 2.5 ended on December 31, 2014. Possible bugs in Joomla 2.5 will not be patched anymore. This forum has been closed. Please update your website to Joomla 3.x

Moderator: ooffick

Forum rules
Please use the official Bug Tracker to report a bug: https://issues.joomla.org
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 200
Joined: Wed Aug 24, 2005 7:20 pm
Location: Los Angeles

JHtmlString::truncate() outputs invalid HTML

Post by dynedain » Wed Dec 07, 2011 5:37 am

If you use JHtmlString::truncate() on text that will split a paragraph, Joomla will ouptut text with the elipses dangling outside of closing paragraph tag.

Reported on:
Joomla 1.7.3


Affected functions:
[USER] Describe the affected functions

Related files:
[USER] List related files when known

Steps to replicate:
Try out the following in a template file

Code: Select all

JHtmlString::truncate("<p>Some paragraph of text goes here.</p>,10);
Expected Output:

Code: Select all

Actual Output (invalid HTML):

Code: Select all

[BugSquad] Confirmed/Unable to confirm/Rejected
Any other comments

Proposed fix(es):
Adjust the tag closing code to place the elipses inside the closing tag instead of outside.

Topic / Artifact ID:
[USER] Enter the cross reference for topic or artifact id/url when submitted

System info:

Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Sun Jan 16, 2011 10:08 pm

Re: JHtmlString::truncate() outputs invalid HTML

Post by Andypants » Tue Mar 13, 2012 5:53 pm

I'm having the same issue. The worst part is that I too, thought it only affected <p> tags but that is not the case. If it was, I'd be able to do a simple str_replace to work-around it.

This also causes problems:
JHtmlString::truncate("<h3>Some paragraph of text goes here.</h3>,10);


Return to “Joomla! 2.5 Bug Reporting”