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

fix(postcss-svgo): fix processing declaration mixing svg and non svg #1043

Merged
merged 1 commit into from Apr 9, 2021

Conversation

ludofischer
Copy link
Collaborator

Close #1040
Skip non-svg data urls even in the case the same declaration
also contains svg. Previously the code assumed declaration only
contained one uri.

Close #1040
Skip non-svg data urls even in the case the same declaration
also contains svg. Previously the code assumed declaration only
contained one uri.
@@ -198,6 +198,15 @@ test('should warn on SVG containing unclosed tags', async () => {
expect(result.messages[0].type).toBe('warning');
});

test('should only warn with svg data uri', async () => {
const css = `@font-face {
src: url("https://example/dfds.woff2") format("woff2"),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Something weird here. The test fails with an error inside postcss-value-parser if I try a relative URL (url(example/dfds.woff2)). I assume url() handling has been tested elsewhere?

@@ -28,6 +28,9 @@ function minify(decl, opts, postcssResult) {
svg = Buffer.from(base64String, 'base64').toString('utf8');
isBase64 = true;
} else {
if (!dataURI.test(value)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the value is not Base64-encoded, the code did not check whether the value was an SVG.

@ludofischer ludofischer merged commit 0e2c3bf into master Apr 9, 2021
@ludofischer ludofischer deleted the fix-svg-warnings branch April 9, 2021 16:56
@ludofischer ludofischer mentioned this pull request Apr 9, 2021
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.

[Bug] : Warnings when Font-Face declaration contains inline SVG
2 participants