Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sanitize-html from 2.1.0 to 2.12.1 fails. Module parse failed: Unexpected token. #663

Open
ricdev opened this issue Apr 17, 2024 · 12 comments
Labels

Comments

@ricdev
Copy link

ricdev commented Apr 17, 2024

To Reproduce

Step by step instructions to reproduce the behavior:

  1. npm install
  2. npm run build

Expected behavior

Clean build.

Describe the bug

Screen Shot 2024-04-17 at 1 16 33 PM

Details

Version of Node.js:

16.18.1

Server Operating System:

MacOs Monterey 12.5.1. Github Actions script.

Additional context:

Relates to #592 (comment) and #592

@ricdev ricdev added the bug label Apr 17, 2024
@BoDonkey
Copy link
Contributor

Two comments:

  1. Node16 is past the EOL - you should upgrade to 18 or 20. This might solve your problem.
  2. I'm not sure what the build script is. It isn't part of the core repo.
    I thought we had done something to pin the version of htmlparser2, but I can't find it in the changelog. My latest version is installing 8.0.1.

@BoDonkey
Copy link
Contributor

Can you provide better steps to replicate the error? Again, there isn't a build script.

@Insomniak313
Copy link

As state here the issue (I'm having the same one) is your webpack version.
You should update to v5. However, im not really satisfied with the author's answer and I'm wondering whether htmlparser2 should have a devDependency on webpack ^5

@BoDonkey
Copy link
Contributor

Thanks @Insomniak313! - I thought it was something with the version of htmlparser2.

@NewEraCracker
Copy link

I am using sanitize-html in backend (...it explodes badly on non esm base with the update) and frontend (...this issue).

Updating Node.js or Webpack is not possible for us on all environments, or restructuring our backend for that matter. Webpack 5 behaves badly with circular imports (our project has over 500 of these) while Webpack 4 just chews 'em all good and produces a working bundle.

What works currently is locking this module using "sanitize-html": "~2.7.3" on the package.json dependencies, then I manually apply commit c5dbdf7 using patch-package to get rid of the security vulnerability.

I was comparing the source code of the project and not much changed. So another solution might be to force at the package.json overrides (npm) and/or resolutions (yarn) "htmlparser2": "^6.0.0" so the good old sub-dependency version is used.

My two cents. Alternatively just make a version 2.7.4 with the security patch. Thank you.

@ElectricS01
Copy link

Could this issue be fixed by bumping htmlparser2 to 9.0.0 or 9.1.0?

@adamreisnz
Copy link

Ran into the same issue, downgrading to 2.1.0 for now helped (as we are stuck on Node 16 for the time being).

Problem is not present when using a higher version of Node/Webpacker, and in our branch with upgraded Node/Webpacker version it works fine with 2.12.1.

@NewEraCracker
Copy link

@adamreisnz read my comment #663 (comment)

What works currently is locking this module using "sanitize-html": "~2.7.3" on the package.json dependencies, then I manually apply commit c5dbdf7 using patch-package to get rid of the security vulnerability.

Using earlier versions will make you vulnerable to exploits.

@adamreisnz
Copy link

adamreisnz commented Nov 8, 2024 via email

@NewEraCracker
Copy link

Version 2.7.3 works on node.js 16 (runs as far back as node.js 12).

Use this instead of 2.1.0 if you can. #663 (comment)

@adamreisnz
Copy link

adamreisnz commented Nov 9, 2024 via email

@adamreisnz
Copy link

Ended up using DOMPurify, as we were also running into #639 in the latest version using Vite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants