cure53 / DOMPurify

DOMPurify - a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG. DOMPurify works with a secure default, but offers a lot of configurability and hooks. Demo:
https://cure53.de/purify
Other
14.12k stars 733 forks source link

errors when imported via requirejs/define #1009

Closed kevindoyleie closed 1 month ago

kevindoyleie commented 1 month ago

Background & Context

Trying to add dompurify to a few legacy apps. It works on the newer one which is using node more purely. The older one is older and requires moving mode modules in to the javascript in to the build folder generated by the build. So when it via the way all other dependencies are imported (define), it compiles fine but there is an issue at run time in the browser.

define([ 'DOMPurify'], function(DOMPurify)
{ 

  const cleanHtml = DOMPurify.sanitize(html); 

I've just imported the latest version of dompurify so maybe I need to use an older version as it's an old app. The app also has a few other libraries in it, such as jquey(3.5.1), requirejs (2.1.15).

Bug

require.js:166 Uncaught Error: Script error for: DOMPurify http://requirejs.org/docs/errors.html#scripterror at makeError (require.js:166:17) at HTMLScriptElement.onScriptError (require.js:1689:36)

kevindoyleie commented 1 month ago

Apologies but I found the issue. It was a self inflicted wound.