(value: string)
| 327 | * function has not thought about. |
| 328 | */ |
| 329 | const sanitizeStyle = (value: string): string => { |
| 330 | const kept: string[] = []; |
| 331 | for (const declaration of value.split(";")) { |
| 332 | const separator = declaration.indexOf(":"); |
| 333 | if (separator === -1) continue; |
| 334 | const property = declaration.slice(0, separator).trim().toLowerCase(); |
| 335 | const propertyValue = declaration.slice(separator + 1).trim(); |
| 336 | if (!ALLOWED_STYLE_PROPERTIES.has(property)) continue; |
| 337 | if (propertyValue === "" || propertyValue.length > 64) continue; |
| 338 | if (!/^[a-z0-9\s%.,()/_-]+$/i.test(propertyValue)) continue; |
| 339 | if (/url\(|\\|expression|@import/i.test(propertyValue)) continue; |
| 340 | kept.push(`${property}:${propertyValue}`); |
| 341 | } |
| 342 | return kept.join(";"); |
| 343 | }; |
| 344 | |
| 345 | const rewriteLocalRef = (name: string, value: string): string => { |
| 346 | if (!LOCAL_REF_ATTRIBUTES.has(name)) return value; |
no test coverage detected