apostrophecms / sanitize-html

Clean up user-submitted HTML, preserving whitelisted elements and whitelisted attributes on a per-element basis. Built on htmlparser2 for speed and tolerance
MIT License
3.68k stars 349 forks source link

sanitizeHtml remove the style attribute #616

Closed vishaltyagi227 closed 1 year ago

vishaltyagi227 commented 1 year ago

Details

Version of Node.js: v18.14.2

Server Operating System: Ubuntu 20.04.5 LTS Additional context: I create a app using the create-react-app. package.json

{
  "name": "sanitize-html-issue",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "sanitize-html": "^2.10.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist":  [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ]
}
BoDonkey commented 1 year ago

Try removing the ; from the last style rule. You could also test using parseStyleAttributes: false to see if it behaves properly.

vishaltyagi227 commented 1 year ago

@BoDonkey Thanks, parseStyleAttributes: false worked