{"record":{"id":"7ca94d354f2a5675","repo":"BigPizzaV3/CodexPlusPlus","slug":"theme-css-css-property","errorCode":null,"errorMessage":"theme.css CSS 属性无效或重复：{property}","messagePattern":"theme\\.css CSS 属性无效或重复：(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":358,"sourceCode":"        let mut rule_declarations = Vec::new();\n        let mut seen = HashSet::new();\n        for declaration in rest[open + 1..close]\n            .split(';')\n            .map(str::trim)\n            .filter(|value| !value.is_empty())\n        {\n            let (property, value) = declaration\n                .split_once(':')\n                .context(\"theme.css 声明语法无效\")?;\n            let property = property.trim();\n            let value = value.trim();\n            if !property\n                .bytes()\n                .enumerate()\n                .all(|(index, byte)| byte.is_ascii_lowercase() || (index > 0 && byte == b'-'))\n                || !seen.insert(property)\n            {\n                bail!(\"theme.css CSS 属性无效或重复：{property}\");\n            }\n            if value.is_empty()\n                || value.chars().count() > 512\n                || value.contains(['{', '}', '<', '>', '!', ';'])\n                || !validate_property_value(property, value)\n            {\n                bail!(\"theme.css 属性值不受 Safe CSS 支持：{property}\");\n            }\n            declarations += 1;\n            if declarations > 512 {\n                bail!(\"theme.css 声明数量超过限制\");\n            }\n            rule_declarations.push((property, value));\n        }\n        if rule_declarations.is_empty() {\n            bail!(\"theme.css 每条规则必须至少包含一个声明\");\n        }\n        parsed.push(SafeCssRule {","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L340-L376","documentation":"Within each rule, declarations are split on ';' and each must have a property name consisting solely of ASCII lowercase letters (with '-' allowed after the first byte) that has not already appeared in the same rule. Uppercase, digits, leading hyphens, unknown identifiers or duplicate properties bail with 'theme.css CSS 属性无效或重复：{property}'.","triggerScenarios":"Vendor-prefixed or camelCase properties (`-webkit-backdrop-filter` rejected due to leading '-', `backgroundColor`); properties with digits (`h1`-style names); writing the same property twice in one rule (`color: #fff; color: #000;`); empty property before ':' or whitespace embedded in the name.","commonSituations":"Copy-pasted CSS containing browser prefixes; authors repeating a property to 'override' earlier values as in plain CSS; auto-generated CSS with uppercase or custom properties (--vars are only allowed on the value side for whitelisted ones).","solutions":["Keep one declaration per property per rule; delete the duplicate occurrence","Lowercase all property names and remove vendor prefixes (`-webkit-backdrop-filter` → `backdrop-filter`)","Restrict properties to the Safe CSS whitelist (color/background-color/border-*/gap/box-shadow/opacity/backdrop-filter/font-*/line-height/letter-spacing/transition-*)"],"exampleFix":"// before\n[data-ds-part=\"main\"] { color: #fff; Color: #000; color: #eee; }\n// after\n[data-ds-part=\"main\"] { color: #eeeeee; }","handlingStrategy":"validation","validationCode":"fn property_ok(prop: &str) -> bool {\n    !prop.is_empty()\n        && prop.bytes().enumerate().all(|(i, b)| b.is_ascii_lowercase() || (i > 0 && b == b'-'))\n}\nfn rule_has_no_duplicate_props(decls: &[(&str, &str)]) -> bool {\n    let mut seen = std::collections::HashSet::new();\n    decls.iter().all(|(p, _)| seen.insert(*p))\n}","typeGuard":null,"tryCatchPattern":"match validate_safe_css(&css) {\n    Err(e) if e.to_string().contains(\"属性无效或重复\") => Err(\"lowercase properties, drop vendor prefixes and duplicates\".into()),\n    other => other,\n}","preventionTips":["Declare each property at most once per rule (later duplicates are not allowed, unlike plain CSS)","Lowercase all property names; never use vendor prefixes or camelCase","Stay within the Safe CSS property whitelist"],"tags":["css","declarations","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}