1(function (Drupal) { 2 "use strict"; 3 4 // Create glightbox namespace if it doesn't exist. 5 if (!Drupal.hasOwnProperty('glightbox')) { 6 Drupal.glightbox = {}; 7 } 8 9 /** 10 * Global function to allow sanitizing captions and control strings. 11 * 12 * @param markup 13 * String containing potential markup. 14 * @return {string} 15 * Sanitized string with potentially dangerous markup removed. 16 */ 17 Drupal.glightbox.sanitizeMarkup = Drupal.glightbox.sanitizeMarkup || function(markup) { 18 if (typeof DOMPurify !== 'undefined') { 19 var purifyConfig = { 20 ALLOWED_TAGS: [ 21 'a', 'b', 'strong', 'i', 'em', 'u', 'cite', 'code', 'br', 'p', 'div', 'h1', 'h2', 'h3', 'h4', 'span' 22 ], 23 ALLOWED_ATTR: [ 24 'href', 'hreflang', 'title', 'target' 25 ] 26 }; 27 if (typeof drupalSettings !== 'undefined' && drupalSettings.hasOwnProperty('dompurify_custom_config')) { 28 purifyConfig = drupalSettings.dompurify_custom_config; 29 } 30 return DOMPurify.sanitize(markup, purifyConfig); 31 } else if (typeof Drupal.checkPlain === 'function') { 32 return Drupal.checkPlain(markup); 33 } else { 34 // Fallback: basic escaping. 35 return String(markup).replace(/[&<>\"]/g, function (c) { 36 return {'&':'&','<':'<','>':'>','"':'"'}[c]; 37 }); 38 } 39 }; 40 41 /** 42 * Enable the GLightbox inline functionality. 43 */ 44 Drupal.behaviors.glightboxInline = { 45 attach: function (context, drupalSettings) { 46 once('glightbox-inline-processed', '.glightbox-inline', context).forEach(el => { 47 // Sanitize every data-* attribute on this element. 48 el.getAttributeNames() 49 .filter(name => name.startsWith('data-')) 50 .forEach(name => { 51 let clean = Drupal.glightbox.sanitizeMarkup(el.getAttribute(name)); 52 if (name === 'data-href') { 53 clean = Drupal.glightbox.sanitizeHref(clean); 54 } 55 el.setAttribute(name, clean); 56 }); 57 }); 58 const options = Object.assign({}, drupalSettings.glightbox || {}, { 59 selector: '.glightbox-inline', 60 }); 61 const lightboxInlineIframe = GLightbox(options); 62 } 63 }; 64 65})(Drupal);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.