← Files Flows by plugin.spaceARCHIVED FILE

lib/project-icon-data.mjs

706 Bytes · Nov 30, 2026 · 00:17 UTC

↓ Download file

// Inline, bounded icons work in the MCP sandbox without third-party requests.
export function isProjectIcon(value) {
  if (typeof value !== 'string' || value.length > 90_000 || !/^data:image\/(png|jpeg|webp|gif|x-icon|vnd.microsoft.icon|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/.test(value)) return false;
  try {
    const svg = atob(value.slice(value.indexOf(',') + 1));
    if (!svg.length || svg.length > 64 * 1024) return false;
    if (!value.startsWith('data:image/svg+xml;')) return true;
    return /<svg\b/i.test(svg) && !/<(?:script|foreignObject|iframe|object|embed)\b|<!DOCTYPE|<!ENTITY|\son\w+\s*=|@import|url\(\s*[^#]|(?:href|src)\s*=\s*["']\s*[^#]/i.test(svg);
  } catch { return false; }
}

SHA-256: 4f2b650b7dfa7b75a0e758091ed1d6d179097d8808d7bf2f7660ea6fa5cf2b3c