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

optimizeSvgEncode unclosed string #105

Closed
gpoitch opened this issue Jul 19, 2017 · 5 comments · Fixed by bem/bem-express#144
Closed

optimizeSvgEncode unclosed string #105

gpoitch opened this issue Jul 19, 2017 · 5 comments · Fixed by bem/bem-express#144

Comments

@gpoitch
Copy link

gpoitch commented Jul 19, 2017

Thanks for the optimizeSvgEncode feature.

It appears to be creating invalid css:
Module build failed: Unclosed string

background-image: url(data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3e%3cpath d='M0 4v24h32V4H0zm6 22H2v-4h4v4zm0-8H2v-4h4v4zm0-8H2V6h4v4zm18 16H8V6h16v20zm6 0h-4v-4h4v4zm0-8h-4v-4h4v4zm0-8h-4V6h4v4zm-18 0v12l8-6z'/%3e%3c/svg%3e);

Look like it's because Inlining inserts without wrapping the whole thing in quotes and there are now unencoded quotes in the svg when using optimizeSvgEncode

@gpoitch
Copy link
Author

gpoitch commented Jul 19, 2017

Looks like this retains the input css's quoting, so this works ok:

.style {
  background-image: url("./image.svg");
}

But this fails:

.style {
  background-image: url(./image.svg);
}

Quotes on file path urls are optional according to the css spec, but maybe this module should enforce adding quotes when inlining.

@sergcen
Copy link
Collaborator

sergcen commented Jul 20, 2017

@gdub22 thanks for feedback. Yes, you're right. I will try fix it soon.

@Realetive
Copy link

replace https://github.com/postcss/postcss-url/blob/master/src/type/inline.js#L81 on

return `'${(options.includeUriFragment && asset.hash) ? encodedStr + asset.hash : encodedStr}'`;

work for me.

Realetive added a commit to Realetive/bem-express-ext that referenced this issue Jul 21, 2017
@sergcen
Copy link
Collaborator

sergcen commented Jul 24, 2017

fixed here #7.1.1

Realetive added a commit to Realetive/bem-express-ext that referenced this issue Jul 24, 2017
Last version of `postcss-url` was have a bug with path without quotes. Now it was fixed: postcss/postcss-url#105 (comment)
@gpoitch
Copy link
Author

gpoitch commented Jul 24, 2017

Thank you. Confirmed it's working.

@gpoitch gpoitch closed this as completed Jul 24, 2017
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 a pull request may close this issue.

3 participants