@vizejs/vite-plugin-musea 0.90.0 → 0.91.0

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/index.mjs CHANGED
@@ -649,6 +649,18 @@ function generateGalleryStyles() {
649
649
  *
650
650
  * Extracted from gallery.ts to keep file sizes manageable.
651
651
  */
652
+ function escapeHtmlAttribute(value) {
653
+ return value.replace(/[&<>"']/g, (char) => {
654
+ switch (char) {
655
+ case "&": return "&amp;";
656
+ case "<": return "&lt;";
657
+ case ">": return "&gt;";
658
+ case "\"": return "&quot;";
659
+ case "'": return "&#39;";
660
+ default: return char;
661
+ }
662
+ });
663
+ }
652
664
  /**
653
665
  * Generate the gallery HTML body (header, sidebar, content, and inline script).
654
666
  */
@@ -656,7 +668,7 @@ function generateGalleryBody(basePath) {
656
668
  return `
657
669
  <header class="header">
658
670
  <div class="header-left">
659
- <a href="${basePath}" class="logo">
671
+ <a href="${escapeHtmlAttribute(basePath)}" class="logo">
660
672
  <svg class="logo-svg" width="32" height="32" viewBox="0 0 200 200" fill="none">
661
673
  <g transform="translate(30, 25) scale(1.2)">
662
674
  <g transform="translate(15, 10) skewX(-15)">
@@ -832,10 +844,11 @@ function generateGalleryScript(basePath) {
832
844
  html += '<div class="gallery">';
833
845
  for (const variant of selectedArt.variants) {
834
846
  const previewUrl = basePath + '/preview?art=' + encodeURIComponent(selectedArt.path) + '&variant=' + encodeURIComponent(variant.name);
847
+ const escapedPreviewUrl = escapeHtml(previewUrl);
835
848
 
836
849
  html += '<div class="variant-card">';
837
850
  html += '<div class="variant-preview">';
838
- html += '<iframe src="' + previewUrl + '" loading="lazy" title="' + escapeHtml(variant.name) + '"></iframe>';
851
+ html += '<iframe src="' + escapedPreviewUrl + '" loading="lazy" title="' + escapeHtml(variant.name) + '"></iframe>';
839
852
  html += '</div>';
840
853
  html += '<div class="variant-info">';
841
854
  html += '<div>';
@@ -843,7 +856,7 @@ function generateGalleryScript(basePath) {
843
856
  if (variant.isDefault) html += ' <span class="variant-badge">Default</span>';
844
857
  html += '</div>';
845
858
  html += '<div class="variant-actions">';
846
- html += '<button class="variant-action-btn" title="Open in new tab" onclick="window.open(\\'' + previewUrl + '\\', \\'_blank\\')"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></button>';
859
+ html += '<button class="variant-action-btn" title="Open in new tab" data-preview-url="' + escapedPreviewUrl + '"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></button>';
847
860
  html += '</div>';
848
861
  html += '</div>';
849
862
  html += '</div>';
@@ -852,11 +865,18 @@ function generateGalleryScript(basePath) {
852
865
  html += '</div>';
853
866
 
854
867
  content.innerHTML = html;
868
+
869
+ content.querySelectorAll('.variant-action-btn[data-preview-url]').forEach(button => {
870
+ button.addEventListener('click', () => {
871
+ const previewUrl = button.dataset.previewUrl;
872
+ if (previewUrl) window.open(previewUrl, '_blank', 'noopener');
873
+ });
874
+ });
855
875
  }
856
876
 
857
877
  function escapeHtml(str) {
858
878
  if (!str) return '';
859
- return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
879
+ return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
860
880
  }
861
881
 
862
882
  // Search