{"_id":"express-html-sanitizer","_rev":"2-fa3c86b719f95f8ad76ddbaf1735664b","name":"express-html-sanitizer","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"express-html-sanitizer","version":"1.0.0","description":"Express JS middleware to cleanup/sanitize json request body in express","main":"index.js","scripts":{"test":"mocha test/tests.js --exit"},"repository":{"type":"git","url":"git+https://github.com/sbr35/express-html-sanitizer.git"},"keywords":["html","parser","sanitizer","express","middleware"],"author":{"name":"Shohidul Bari"},"license":"MIT","dependencies":{"sanitize-html":"^2.0.0"},"devDependencies":{"body-parser":"^1.19.0","chai":"^4.2.0","chai-http":"^4.3.0","express":"^4.17.1","lodash":"^4.17.20","mocha":"^8.1.3"},"gitHead":"d12d7265c5897b3aaffff986f3e97309e8eb9d6b","bugs":{"url":"https://github.com/sbr35/express-html-sanitizer/issues"},"homepage":"https://github.com/sbr35/express-html-sanitizer#readme","_id":"express-html-sanitizer@1.0.0","_nodeVersion":"14.11.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-6/7nd6P5LGmJd0PmrcrU9TVxTpblqQzz8ReK+Prc5uCaEiO5IUKGhyTIomFlAlvRpaqX1wAQk6dfb/t5cvm3Tg==","shasum":"efffaf826815535f066c4b6d99f5f6783c87dd16","tarball":"https://registry.npmjs.org/express-html-sanitizer/-/express-html-sanitizer-1.0.0.tgz","fileCount":4,"unpackedSize":5043,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJffJdYCRA9TVsSAnZWagAAN8MP/RKV2OOBAb/om0gTC7ZV\nDgs7OnljhGlrvMp/894j+Kh10GLTXYHzBRSvGJXfRZstqIPSKbZ9T9OfgPvZ\npYJQkO+hgfUI5cPrdcgUmsAQoiWA8fOza9RAC+om70fHzxITQq+j4J7x6czf\nVtZf90/xu0NSY6GFWNynh0XuCyKxrmLsWQie7EdEJuGwZhtevjovysZ0Mt6w\nnzXjl9RKD9jHy0hw15R8LzKRzCAZvoQr0LijgLZSqKMmegf3qc/SD+wq8QSL\nHAZ2vtRrz7lgvtYwP2eaOeP6LTT5HLKFQYu8Oab4KV4G6vI3LrtlLJd5KIgS\no6nBYghRokgoz1dZeerapUXXNJ+yEn2+SPSrl6/BGYKjmH5RUqyc2NGyhklS\n7qlx/n+Hx2lZ9eVjzb58k19/UVfZXA6Axj5EsJ6gKTr4aWn7ZCtkm0s8/wS0\nN7naUCbAE90X5cXDGE1p9Gr9vjCWwM8ZeeSxaKWtEMMoZM/5SxWesWtUBa1d\npD+6yF+J1YL/btmSuAmHm0o1BTV2k7jn5fUbWqj3J4xEJriaoQB7V18VjqJ9\nZJU3OE6SkRs53TQ8rR3F8UGN5NLI+azceIbT1F628d+4aTB/eDCPwKPCCYjq\n+bTHpMX8+N26AqjoB1weD2IMd8u037XgSpDonbgX+nm7GBhheb107st4lN21\nlX85\r\n=e3vI\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDMfdXoilY6aletGe8wms4INjXtvLQQbvvU6bQclsCp1AIhAKVupFKDYrXzVFM8gefhlgKPZArhojrBvZu3Iio02dXJ"}]},"maintainers":[{"name":"sbr35","email":"shohidulbari18@gmail.com"}],"_npmUser":{"name":"sbr35","email":"shohidulbari18@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/express-html-sanitizer_1.0.0_1602000727850_0.7181516272456694"},"_hasShrinkwrap":false},"1.0.1":{"name":"express-html-sanitizer","version":"1.0.1","description":"Express JS middleware to cleanup/sanitize json request body in express","main":"index.js","scripts":{"test":"mocha test/tests.js --exit"},"repository":{"type":"git","url":"git+https://github.com/shohidulbari/express-html-sanitizer.git"},"keywords":["html","parser","sanitizer","express","middleware"],"author":{"name":"Shohidul Bari"},"license":"MIT","dependencies":{"sanitize-html":"^2.0.0"},"devDependencies":{"body-parser":"^1.19.0","chai":"^4.2.0","chai-http":"^4.3.0","express":"^4.17.1","lodash":"^4.17.20","mocha":"^8.1.3"},"gitHead":"076f80b30dda0b3be1294cb7710a56442e556078","bugs":{"url":"https://github.com/shohidulbari/express-html-sanitizer/issues"},"homepage":"https://github.com/shohidulbari/express-html-sanitizer#readme","_id":"express-html-sanitizer@1.0.1","_nodeVersion":"12.18.4","_npmVersion":"6.14.6","dist":{"integrity":"sha512-EZ52gJhFgNuD5bo2eFhWvz7snlgiQV5QXEflkVu1T3ZKoIQpPX1beuG90UZ4Da1Au8GxMhDOxUKI7wXFT0u5Jg==","shasum":"964c05588890e57961dc575befd2df81efb7802a","tarball":"https://registry.npmjs.org/express-html-sanitizer/-/express-html-sanitizer-1.0.1.tgz","fileCount":4,"unpackedSize":5080,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgTd/lCRA9TVsSAnZWagAAbOAP/A2NRnRdF5FtL8ksnPaU\nZ+KtKIjrRV4eXiXDlqykB4ZVrggcwEAhkvXhaek69eFzws55zJQYhRW6e+uK\nNusfESLNkUj7NAoiyf4iMfvZfQV8yTj/T/8UdHCXaxWpKfpejSo8fWgm9g9I\nWL7mw500wT2urKRagi3JU52YT84MT48pyx2yrZrswJvN3vCtBiczz8riFrlV\n9u30leDTR0VXlBiS3M/r2Ex/bCWe2egh+Wb0tuu6gT8lvk1sPCe7J7TtdHPs\nA/jIv1KQ45wzE/gLmgvT2Ix3kZr9hKkHxIi5aQ9InmKwXpcve5F6mQwMspU7\nUYEyQyfjuQ+k+0IV8vcLJ/mQWTX7kZ3De9W2cDvNidnlTjpTKBB3jRuhg7SL\nB+wNvMRSEf9JWNrm8lmQKZBHckez/GQlU+fOB461rNNuNAOC38POGs2kaN0x\nU5+UW/9ZiLGsrLA7/e8d70OvHR2jed1XNUYKIaPKmjmFNxNYqwbQuJhfIUSI\nYwIHcR1LhZ25txBlo/Ck2qN9gp8aSGv++zJnEtq7HaA7qA3Ewu6esvCPwpcj\nKFo6Z+wUhi+e2qc/5a+a4y1IUI6GtB4QyqkjQM4ccxpH9JiNamTBC4R72P3B\nrOkb7ALEWm8TS7LWo0eM8jy9V18RsX3nM5rj5uY3oNRgEpiRUxC8yhlkuIc5\nAizB\r\n=2ZJO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEPf49f2UAJqndQjqR3VCrO6pX/Z+lyV9l6R/LlaPCpBAiEA1BbbjidsShKziFK0jxGwl2g2420bnKGCueBHcZjdIek="}]},"_npmUser":{"name":"sbr35","email":"shohidulbari18@gmail.com"},"directories":{},"maintainers":[{"name":"sbr35","email":"shohidulbari18@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/express-html-sanitizer_1.0.1_1615716325193_0.27258390396483057"},"_hasShrinkwrap":false}},"time":{"created":"2020-10-06T16:12:07.850Z","1.0.0":"2020-10-06T16:12:07.961Z","modified":"2022-05-01T23:04:14.914Z","1.0.1":"2021-03-14T10:05:25.340Z"},"maintainers":[{"name":"sbr35","email":"shohidulbari18@gmail.com"}],"description":"Express JS middleware to cleanup/sanitize json request body in express","homepage":"https://github.com/shohidulbari/express-html-sanitizer#readme","keywords":["html","parser","sanitizer","express","middleware"],"repository":{"type":"git","url":"git+https://github.com/shohidulbari/express-html-sanitizer.git"},"author":{"name":"Shohidul Bari"},"bugs":{"url":"https://github.com/shohidulbari/express-html-sanitizer/issues"},"license":"MIT","readme":"# express-html-sanitizer\n`express-html-sanitizer` provides a middleware for <a href=\"http://expressjs.com/\">Express JS</a>  to cleanup/sanitize `JSON` request body in express `RESTful Service` or in any `JSON` input containing unwanted `HTML` tags.\n\n`express-html-sanitizer` uses excellent <a href=\"https://www.npmjs.com/package/sanitize-html\">sanitize-html</a> module recursively for sanitizing `JSON` data with unwanted `HTML` tags. You can  put this middleware at root level to sanitize request body and provide a clean html sanitized payload for next middleware.\n\n# Requirements\n`express-html-sanitizer` is intended for use with Express JS as a middleware. That's pretty much it. `express-html-sanitizer` is built on the excellent `sanitize-html` module.\n\n## How to use\nInstall module:\n```bash\nnpm install express-html-sanitizer\n```\nImport the module:\n```js\nconst sanitizer  = require('express-html-sanitizer')\n```\nGet the middleware:\n```js\nconst sanitizeReqBody = sanitizer();\n```\n\nyou can make some configuration for allowed tags and other like exactly <a href=\"https://www.npmjs.com/package/sanitize-html\">sanitize-html</a> and pass it as argument to get configured middleware. For details configuration you can see <a href=\"https://www.npmjs.com/package/sanitize-html\">sanitize-html</a> module documentation.\n```js\nconfig = {\n\tallowedTags:  [  'b',  'i',  'em',  'strong',  'a'  ],\n\tallowedAttributes:  {'a':  [  'href'  ] },\n\tallowedIframeHostnames:  ['www.youtube.com']\n}\nconst sanitizeReqBody = sanitizer(config);\n```\nAdd a json `body-parser` middleware\n```js\napp.use(require('body-parser').json());\n```\n\nNow use it in your `Express App` . \n```js\napp.use(sanitizeReqBody);\n```\n### Boom!!\n\n## Full Example\n```js\nconst express = require('express');\nconst sanitizer = require('express-html-sanitizer');\nconst app = express();\n\n//Make some custom configuration if you want(optional)\nconfig = {\n\tallowedTags:  [  'b',  'i',  'em',  'strong',  'a'  ],\n\tallowedAttributes:  {'a':  [  'href'  ] },\n\tallowedIframeHostnames:  ['www.youtube.com']\n}\n\n//Get the middleware\nconst sanitizeReqBody = sanitizer(config);\n\n//Add body-parser middleware\napp.use(require('body-parser').json());\n\n//Add express-html-sanitizer middleware\napp.use(sanitizeReqBody);\n\napp.post('/post', (req, res, next) => {\n\t//get sanitized req.body\n})\n\napp.listen(8080, ()=> {\n\tconsole.log(\"Express server started\");\n})\n``` \n\n# Support\nFell free to open issues on <a href=\"https://github.com/sbr35/express-html-sanitizer\">github</a>\n\n","readmeFilename":"README.md"}