Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions plugins/system/sef/sef.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ public function onAfterRender()
// Replace all unknown protocols in CSS background image.
if (strpos($buffer, 'style=') !== false)
{
$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[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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove '$6' from '$4$5$6)' and I can mark as a successful test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not remember now, but by looking at $6 it is the closing quote ? which is either ' or "

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are six, did you test it without $6 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

$this->checkBuffer($buffer);
}

Expand Down