{"record":{"id":"b1a923bfaceb75dd","repo":"garrytan/gstack","slug":"css-value-rejected-contains-potentially-dangerous","errorCode":null,"errorMessage":"CSS value rejected: contains potentially dangerous pattern.","messagePattern":"CSS value rejected: contains potentially dangerous pattern\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/cdp-inspector.ts","lineNumber":509,"sourceCode":"/**\n * Modify a CSS property on an element.\n * Uses CSS.setStyleTexts in headed mode, falls back to inline style in headless.\n */\nexport async function modifyStyle(\n  page: Page,\n  selector: string,\n  property: string,\n  value: string\n): Promise<StyleModification> {\n  // Validate CSS property name\n  if (!/^[a-zA-Z-]+$/.test(property)) {\n    throw new Error(`Invalid CSS property name: ${property}. Only letters and hyphens allowed.`);\n  }\n\n  // Validate CSS value — block data exfiltration patterns\n  const DANGEROUS_CSS = /url\\s*\\(|expression\\s*\\(|@import|javascript:|data:/i;\n  if (DANGEROUS_CSS.test(value)) {\n    throw new Error('CSS value rejected: contains potentially dangerous pattern.');\n  }\n\n  let oldValue = '';\n  let source = 'inline';\n  let sourceLine = 0;\n  let method: 'setStyleTexts' | 'inline' = 'inline';\n\n  try {\n    // Try CDP approach first\n    const session = await getOrCreateSession(page);\n    const result = await inspectElement(page, selector);\n    oldValue = result.computedStyles[property] || '';\n\n    // Find the most-specific matching rule that has this property\n    let targetRule: InspectorResult['matchedRules'][0] | null = null;\n    for (const rule of result.matchedRules) {\n      if (rule.userAgent) continue;\n      const hasProp = rule.properties.some(p => p.name === property);","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/cdp-inspector.ts#L491-L527","documentation":"Error \"CSS value rejected: contains potentially dangerous pattern.\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/cdp-inspector.ts:509 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}