@versatiles/svg-renderer 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/maplibre.cjs CHANGED
@@ -16438,6 +16438,39 @@ function querySelector(parent, selector) {
16438
16438
  throw new Error(`Element not found: ${selector}`);
16439
16439
  return el;
16440
16440
  }
16441
+ const ALLOWED_TAGS = new Set(['a', 'b', 'i', 'em', 'strong', 'span']);
16442
+ function sanitizeHTML(html) {
16443
+ const parser = new DOMParser();
16444
+ const doc = parser.parseFromString(html, 'text/html');
16445
+ return sanitizeNode(doc.body).textContent ?? '';
16446
+ }
16447
+ function sanitizeNode(node) {
16448
+ if (node.nodeType === Node.TEXT_NODE) {
16449
+ return document.createTextNode(node.textContent ?? '');
16450
+ }
16451
+ if (node.nodeType === Node.ELEMENT_NODE && node instanceof HTMLElement) {
16452
+ const tag = node.tagName.toLowerCase();
16453
+ let span;
16454
+ if (!ALLOWED_TAGS.has(tag)) {
16455
+ span = document.createDocumentFragment();
16456
+ }
16457
+ else {
16458
+ span = document.createElement(tag);
16459
+ if (tag === 'a') {
16460
+ const href = node.getAttribute('href');
16461
+ if (href && /^https?:\/\//i.test(href))
16462
+ span.setAttribute('href', href);
16463
+ span.setAttribute('target', '_blank');
16464
+ span.setAttribute('rel', 'noopener noreferrer');
16465
+ }
16466
+ }
16467
+ for (const child of Array.from(node.childNodes)) {
16468
+ span.append(sanitizeNode(child));
16469
+ }
16470
+ return span;
16471
+ }
16472
+ return document.createTextNode('');
16473
+ }
16441
16474
  class SVGExportControl {
16442
16475
  map;
16443
16476
  container;
@@ -16515,9 +16548,9 @@ class SVGExportControl {
16515
16548
  .filter((a) => !!a)),
16516
16549
  ];
16517
16550
  if (attributions.length > 0) {
16518
- noticeEl.textContent =
16551
+ noticeEl.innerHTML =
16519
16552
  "When publishing the exported map, don't forget to add an attribution like: " +
16520
- attributions.join(', ');
16553
+ attributions.map(sanitizeHTML).join(', ');
16521
16554
  }
16522
16555
  else {
16523
16556
  noticeEl.textContent =