Improve CSS attribute value unquote regular expression (#17864)

This commit is contained in:
fisker Cheung authored and GitHub committed 2025-09-09 17:14:44 +08:00
1 parent fcf5b82cdf
commit 1c18b71833
1 file changed
+8 -2
+8 -2
View File
@@ -128,8 +128,14 @@ function clean(original, cloned, parent) {
value = value.slice(0, -1);
}
// TODO[@fisker]: fix the unquote logic, should use back reference
cloned.value = value.trim().replaceAll(/^["']|["']$/gu, "");
value = value.trim();
value = value.replace(
/^(?<quote>["'])(?<value>.*?)\k<quote>$/u,
"$<value>",
);
cloned.value = value;
delete cloned.quoted;
}
}