Fix SEF plugin breaking HTML while trying to make inline background url paths absolute#11266
Fix SEF plugin breaking HTML while trying to make inline background url paths absolute#11266rdeutz merged 5 commits intojoomla:stagingfrom
Conversation
|
Works for me now. Thx |
|
please visit and click "Test this" and the select "Tested successfuly" to mark a successful test |
|
I have tested this item ✅ successfully on ff76cd8 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11266. |
|
I have tested this item ✅ successfully on ff76cd8 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11266. |
|
See results: This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11266. |
|
Rtc This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11266. |
|
No longer RTC, it needs retesting, since i added handling of: to fix issue: #7267 |
plugins/system/sef/sef.php
Outdated
| { | ||
| $regex = '#style=\s*[\'\"](.*):\s*url\s*\([\'\"]?(?!/|' . $protocols . '|\#)([^\)\'\"]+)[\'\"]?\)#m'; | ||
| $buffer = preg_replace($regex, 'style="$1: url(\'' . $base . '$2$3\')', $buffer); | ||
| $regex_url = '\s*url\s*\(([\'\"]|\&\#0?3[4|9];)?(?!/|\&\#0?3[4|9];|' . $protocols . '|\#)([^\)\'\"]+)([\'\"]|\&\#0?3[4|9];)?\)'; |
There was a problem hiding this comment.
Do you need pipe in [4|9]?
There was a problem hiding this comment.
yes, in total we want to detect these:
34, 39, 034, 039
There was a problem hiding this comment.
but now i see, yes pipe is a mistake, although it should not cause a problem since character #\03| does not exist
|
I have removed the redudant pipe character, if that case was ever encountered then HTML is already broken |
plugins/system/sef/sef.php
Outdated
| $buffer = preg_replace($regex, 'style="$1: url(\'' . $base . '$2$3\')', $buffer); | ||
| $regex_url = '\s*url\s*\(([\'\"]|\&\#0?3[49];)?(?!/|\&\#0?3[49];|' . $protocols . '|\#)([^\)\'\"]+)([\'\"]|\&\#0?3[49];)?\)'; | ||
| $regex = '#style=\s*([\'\"])(.*):' . $regex_url . '#m'; | ||
| $buffer = preg_replace($regex, 'style=$1$2: url($3' . $base . '$4$5$6)', $buffer); |
There was a problem hiding this comment.
Please remove '$6' from '$4$5$6)' and I can mark as a successful test.
There was a problem hiding this comment.
I do not remember now, but by looking at $6 it is the closing quote ? which is either ' or "
There was a problem hiding this comment.
Whole regex:
#style=\s*([\'\"])(.*):\s*url\s*\(([\'\"]|\&\#0?3[49];)?(?!/|\&\#0?3[49];|' . $protocols . '|\#)([^\)\'\"]+)([\'\"]|\&\#0?3[49];)?\)#
#style=\s*(______)(__):\s*url\s*\((___________________)?(?!/|\&\#0?3[49];|' . $protocols . '|\#)(__________)(___________________)?\)#
I counted to five:)
There was a problem hiding this comment.
There are six, did you test it without $6 ?
There was a problem hiding this comment.
Yes, I tested on your examples. If I remove $5 too then ' or " are missing. Without $6 everything is OK.
(?!....) - it is not captured by regex.
There was a problem hiding this comment.
Yes, i have taken time to look at it again and counted the blocks,
you are right, the $6 capturing block does not exist,
there are only 5 capturing blocks in the regular expressions, i will update the PR,
I missed it , as it does not cause error because $6 capturing block is always empty
|
I have removed the redudant $6 replacement of the 6th capturing block, as it does not the 6th capturing block, does not exist. |
|
I have tested this item ✅ successfully on b616e60 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/11266. |
1 similar comment
|
I have tested this item ✅ successfully on b616e60 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/11266. |
|
RTC Thanks @ggppdk This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/11266. |




Pull Request for Issue #11264 and issue: #7267
The SEF plugin attempts to make inline background url paths absolute but adding / or /jfolder/ to them
Example of broken cases:
the above will become:
which are obviously broken
Summary of Changes
Added handling of cases
Testing Instructions
Apply patch and at the bottom of index.php of protostar (just before </body> TAG) add:
after patch the will be no broken HTML
PS: there is almost zero performance impact to the regexp , we simply capture the quotes and use them, the regexp has no other changes