MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / sanitizeStyle

Function sanitizeStyle

packages/core/sdk/src/artifact-preview.ts:329–343  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

327 * function has not thought about.
328 */
329const 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
345const rewriteLocalRef = (name: string, value: string): string => {
346 if (!LOCAL_REF_ATTRIBUTES.has(name)) return value;

Callers 1

sanitizeAttributesFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected