?
Referenced as Pull Request for: # 6394
avatar MarkRS-UK
MarkRS-UK
22 Feb 2015

Truncated text from articles containing an html element with numerals (currently only "h"(eader) exists) and another html element whose closing tag is removed in the truncation, will produce invalid html.
This is because the regex in string.truncate fails to match closing tags with numerals.

Steps to reproduce the issue

Put text like <h1>Title</h1><p>Enough text to get truncated</p> at the beginning of an article that is then displayed with string.truncate.

Expected result

The html <h1>Title</h1><p>Partial text</p>... is produced

Actual result

The html <h1>Title</h1><p>Partial text</p></h1>... is produced.
This is invalid in that it produces a second, unmatched, closing h1 tag.

System information (as much as possible)

The incorrect code is in line 100 in /libraries/cms/html/string.php.
The match string is #</([a-z]+)>#iU when it should be #</([a-z][a-z0-9]*)>#iU
to match closing tags with numerals.
This renders correct html in the above example.
If we wanted to cover the case where a closing tag like </h1 > was being matched, the pattern should be #</([a-z][a-z0-9]*)\b(?:[^>]*?)>#iU

Additional comments

This error, of course, afflicts truncateComplex too, since it calls truncate.
This code is called anywhere where a short extract from html is displayed, six different views in core components (content, tags, finder, newsfeed).

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
5.00

avatar MarkRS-UK MarkRS-UK - open - 22 Feb 2015
avatar MarkRS-UK
MarkRS-UK - comment - 22 Feb 2015

Text fixed on gitHub, but that's not reflected here.
Click the black cat icon at the top of the Joomla issue tracker page to see the gitHub page that looks much better.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6149.
avatar infograf768 infograf768 - change - 22 Feb 2015
Priority Urgent Medium
avatar brianteeman brianteeman - change - 23 Feb 2015
Labels Added: ?
avatar brianteeman brianteeman - change - 25 Feb 2015
Labels Removed: ?
avatar brianteeman brianteeman - change - 25 Feb 2015
Labels Added: ?
avatar Erftralle
Erftralle - comment - 28 Feb 2015

Confirmed.

To reproduce the problem I created a new menu entry to show a list of my archived articles and configured it to show the intro text with a limit of 20 chars. This of course assumes that archived articles are available having an intro text containing the sample text mentioned above.

I think when searching for patterns like h1 in the opening tags they should be searched in the closing tags as well.
I confirm, that the patterns suggested by @MarkRS-UK are working fine for me.
I would prefer the second one (#</([a-z][a-z0-9]*)\b(?:[^>]*?)>#iU), as it seems to be more robust.

@MarkRS-UK, you should open a pull request for this issue.

avatar brianteeman brianteeman - change - 28 Feb 2015
Status New Confirmed
avatar zero-24
zero-24 - comment - 28 Feb 2015

@MarkRS-UK

Text fixed on gitHub, but that's not reflected here.

you need to use: http://issues.joomla.org/tracker/joomla-cms/6149/edit else the tracker will sync back the changes :smile:

As you have code you can easy submit a pull request. If you don't know how see here: https://docs.joomla.org/Using_the_Github_UI_to_Make_Pull_Requests

Thanks!


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6149.
avatar MarkRS-UK MarkRS-UK - reference | - 11 Mar 15
avatar zero-24 zero-24 - change - 12 Mar 2015
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2015-03-12 23:18:13
Closed_By zero-24
avatar joomla-cms-bot joomla-cms-bot - change - 12 Mar 2015
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2015-03-12 23:18:13
avatar joomla-cms-bot joomla-cms-bot - close - 12 Mar 2015
avatar joomla-cms-bot joomla-cms-bot - close - 12 Mar 2015
avatar joomla-cms-bot
joomla-cms-bot - comment - 12 Mar 2015

Set to "closed" on behalf of @zero-24 by The JTracker Application at issues.joomla.org/joomla-cms/6149

avatar zero-24
zero-24 - comment - 12 Mar 2015

Closing as we have a pull request here: http://issues.joomla.org/tracker/joomla-cms/6394 Thanks!


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6149.

Add a Comment

Login with GitHub to post a comment