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
fix(postcss-svgo): make sure "new URL" does not crash on relative urls #1050
Conversation
Thanks, can you add test case? |
The same problems. Successfully figured it out by doing the same modification as this issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add test
Sorry, but I don't have time to do that in the foreseeable future. |
I have the same issue, but I don't believe it's caused by relative URLs, but by the # in the url, I with the same error but:
The similarities being the #iefix. |
The issue is not the relative url, but that it does not contain a hostname |
Oh I see. That makes more sense now. I tried forking the code and adding a test prior to this patch being implemented but my jest skills are pretty basic. I was unable to reproduce the issue this way and I'm currently investigating a way to provide a failing test. Any ideas where I should look? This is what I tried adding but this passes: test('should not crash on urls containing a relative URL', async () => {
const css = `@font-face {
src: url("../assets/font.eot#iefix") format("eot");
}`;
const result = await postcss(plugin()).process(css, { from: undefined });
expect(result.messages.length).toBe(0);
}); |
Hi all, I have created another PR to fix this issue as I wanted to refactor to make the control flow more readable. I've also added a failing test. |
Fix #1050 Ensure it never starts processing an URL before making sure it is an inine SVG.
Fix #1050 Ensure it never starts processing an URL before making sure it is an inine SVG.
Fix #1050 Ensure it never starts processing an URL before making sure it is an inine SVG.
I'm using cssnano not directly, but as a dependency through "css-minimizer-webpack-plugin".
After the update to "css-minimizer-webpack-plugin" 2.0.0 and in turn cssnano 5.0.0 webpack fails with an error:
To Reproduce
In my Stylesheet I have a part of SASS code:
That gets processed by webpack. Because the svg is less then 10kb it gets inlined, so the final output Looks like this:
When I build the script it fails at this "new URL", because it does process each entry in the url list and URL does not work with relative paths.
This fix should resolve this issue, by only creating a new URL if a base64 encoded url is used.