Skip to content

system/sef plugin background image parser regexp bug #7267

@nextend

Description

@nextend

Bug

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(&#039;http://test.org/test.png&#039;)"></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_'":\s_url\s_(['"]?(?!/|' . $protocols . '|#)([^)\'\"]+)['"]?)#m';

Test:

<div style="background-image: url(&#039;http://test.org/test.png&#039;)"></div>

Result:

<div style="background-image: url("/my/site/path/&#039;http://test.org/test.png&#039;")"></div>

Desired result: - (Regexp do not match this url.)

<div style="background-image: url(&#039;http://test.org/test.png&#039;)"></div>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions