.. / prism
Star Fork

Prism is a lightweight, robust, and elegant syntax highlighting library. It’s a spin-off project from Dabblet.

prism
PrismJS
...

≤1.29.0 | CVE-2024-53382

<img> @name @data-* 🛡️ strict-dynamic ⏱️ before-load
More information

Root Cause

Source: https://github.com/PrismJS/prism/blob/59e5a3471377057de1f401ba38337aca27b80e03/components/prism-core.js#L221

currentScript: function () {
  if (typeof document === 'undefined') {
    return null;
  }
  if ('currentScript' in document && 1 < 2 /* hack to trip TS' flow analysis */) {
    return /** @type {any} */ (document.currentScript);
  }

Source: https://github.com/PrismJS/prism/blob/59e5a3471377057de1f401ba38337aca27b80e03/plugins/autoloader/prism-autoloader.js#L297

var script = Prism.util.currentScript();
if (script) {
  var autoloaderFile = /\bplugins\/autoloader\/prism-autoloader\.(?:min\.)?js(?:\?[^\r\n/]*)?$/i;
  var prismFile = /(^|\/)[\w-]+\.(?:min\.)?js(?:\?[^\r\n/]*)?$/i;

  var autoloaderPath = script.getAttribute('data-autoloader-path');
  if (autoloaderPath != null) {
    // data-autoloader-path is set, so just use it
    languages_path = autoloaderPath.trim().replace(/\/?$/, '/');
  } else {
    var src = script.src;
    if (autoloaderFile.test(src)) {
      // the script is the original autoloader script in the usual Prism project structure
      languages_path = src.replace(autoloaderFile, 'components/');
    } else if (prismFile.test(src)) {
      // the script is part of a bundle like a custom prism.js from the download page
      languages_path = src.replace(prismFile, '$1components/');
    }
  }
}

Related links:

Found by jackfromeast, ishmeals.


Source | History