From 26ed91122085f4241b93e4352c9971ca0ed01e4f Mon Sep 17 00:00:00 2001 From: Krister Kari Date: Wed, 22 Feb 2023 13:56:09 -0300 Subject: [PATCH] operator-no-unspaced: make data uri regex less strict (#767) --- src/rules/operator-no-unspaced/__tests__/index.js | 14 ++++++++++++++ src/rules/operator-no-unspaced/index.js | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/rules/operator-no-unspaced/__tests__/index.js b/src/rules/operator-no-unspaced/__tests__/index.js index 757c4eb8..2e8bf2df 100644 --- a/src/rules/operator-no-unspaced/__tests__/index.js +++ b/src/rules/operator-no-unspaced/__tests__/index.js @@ -92,6 +92,20 @@ testRule({ { code: `div { background: url(data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0Ljk1IDEwIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6IzQ0NDt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPmFycm93czwvdGl0bGU+PHJlY3QgY2xhc3M9ImNscy0xIiB3aWR0aD0iNC45NSIgaGVpZ2h0PSIxMCIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxLjQxIDQuNjcgMi40OCAzLjE4IDMuNTQgNC42NyAxLjQxIDQuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iMy41NCA1LjMzIDIuNDggNi44MiAxLjQxIDUuMzMgMy41NCA1LjMzIi8+PC9zdmc+) }`, description: "background image with base64 data, issue #561" + }, + { + code: ` + .foo { + background-image: url('data:image/svg+xml,'); + } + `, + description: "background image with an svg, issue #605" + }, + { + code: ` + $accordion-button-active-icon: url("data:image/svg+xml;charset=utf-8,") !default; + `, + description: "data uri inside a variable, issue #605" } ], diff --git a/src/rules/operator-no-unspaced/index.js b/src/rules/operator-no-unspaced/index.js index c5e5fab8..cfa95f86 100644 --- a/src/rules/operator-no-unspaced/index.js +++ b/src/rules/operator-no-unspaced/index.js @@ -156,7 +156,7 @@ export function calculationOperatorSpaceChecker({ root, result, checker }) { return results; } - const dataURIRegex = /^url\(\s*['"]?data:.+;base64,.+['"]?\s*\)$/; + const dataURIRegex = /^url\(\s*['"]?data:.+['"]?\s*\)/; root.walk(item => { if (item.prop === "unicode-range") {