Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue with "url(""); ... any other css code .. url("file.jpg"); in one line #337

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

hscheffknecht
Copy link

For CSS files with url("") and any other url() within one line, the second file was ignored.

See https://regex101.com/r/IkhmxT/2

Sure, "url()" is invalid CSS syntax, but this should be ignored and other URLs in the same line should get handled correctly.

@xerc
Copy link
Contributor

xerc commented Sep 7, 2021

please check for both ["] & ['] ; /url\((["']?)([^"']+?)\1\)/i

@hscheffknecht
Copy link
Author

Done

@@ -252,7 +252,7 @@ protected function combineImports($source, $content, $parents)
*/
protected function importFiles($source, $content)
{
$regex = '/url\((["\']?)(.+?)\\1\)/i';
$regex = '/url\((["\']?)([^"\']+?)\\1\)/i';
Copy link
Owner

Choose a reason for hiding this comment

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

This will be a problem when a quote is encountered inside the url.
I think changing the regex to '/url\((["\']?)(.*?)\\1\)/i'; instead of '/url\((["\']?)(.+?)\\1\)/i'; (note the * instead of +, which would allow an empty url value) should also work.
Could you confirm whether that fixes your issue, and resubmit if so?
Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

an empty URL should not get parsed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants