The problem is that I'm using images in the style attributes for background images and I'm set the image urls with a full url:
<div style="background-image: url('http://test.org/test.png')"></div>
Note that the ' in the url() are properly encoded for HTML attributes. This is when the issue comes, the following regexp only match the not encoded ' and " characters and not the encoded ones. The regexp should be fixed by adding
' => '
" => "
The regexp is in plugins/system/sef/sef.php which used to find image urls in style attributes to fix them to the current site's relative path:
$regex = '#style\s=\s\'\":\surl\s([\'\"]?(?!/|' . $protocols . '|#)([^)\'\"]+)[\'\"]?)#m';
<div style="background-image: url('http://test.org/test.png')"></div>
<div style="background-image: url("/my/site/path/'http://test.org/test.png'")"></div>
<div style="background-image: url('http://test.org/test.png')"></div>
Labels |
Added:
?
|
Category | ⇒ | Router / SEF |
For us the solution was to use uppercase URL in our HTML, as the SEF preg_match do not ignore case :)
Also I have one other use case when the regexp fails. Nowadays protocol relative urls are popular, so this would be perfect if you have a site with http and https too:
But the regular expression is not able to match the protocol so it fails and adds the previously mentioned path to the url.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-08-03 12:49:55 |
Closed_By | ⇒ | brianteeman |
Closed as we have a PR for testing #11412
The regular expression has some negative look ahead to avoid matching things like:
url( '/
url( 'http://
we could add & # 039; to the negative lookahead:
Replacing:
with: