Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix: prevent creating css variable with invalid name (#4319)

Bogdan Chadkin4168a2dd8085
diff --git a/apps/builder/app/builder/features/style-panel/sections/advanced/advanced.tsx b/apps/builder/app/builder/features/style-panel/sections/advanced/advanced.tsx
index bf97095f63..95d5ae7d85 100644
--- a/apps/builder/app/builder/features/style-panel/sections/advanced/advanced.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/advanced/advanced.tsx
@@ -1,3 +1,4 @@
+import { lexer } from "css-tree";
import { colord } from "colord";
import {
memo,
@@ -111,10 +112,14 @@ const matchOrSuggestToCreate = (
if (isFeatureEnabled("cssVars") === false) {
return matched;
}
- if (search.trim().startsWith("--")) {
+ const propertyName = search.trim();
+ if (
+ propertyName.startsWith("--") &&
+ lexer.match("<custom-ident>", propertyName).matched
+ ) {
matched.unshift({
- value: search.trim(),
- label: `Create "${search.trim()}"`,
+ value: propertyName,
+ label: `Create "${propertyName}"`,
});
}
return matched;