Socket
Socket
Sign inDemoInstall

xss-scrubber

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    xss-scrubber

Scrubs xss content in a JavaScript object


Version published
Weekly downloads
21
decreased by-41.67%
Maintainers
1
Install size
4.94 kB
Created
Weekly downloads
 

Readme

Source

xss-scrubber

Scrubs xss content of any JavaScript object

Usage

const JsonScrubber = require("xss-scrubber");
...
...
console.log(JsonScrubber(obj));

Examples

** String **
console.log(JsonScrubber('<script>alert("xss");</script>'));
// &lt;script&gt;alert("xss");&lt;/script&gt;

** Array **
console.log(JsonScrubber(['<img>hi! this is @ test</img>', 123, '<script>alert("xss");</script>', 'a']));
// [ '&lt;img&gt;hi! this is @ test&lt;/img&gt;',123,'&lt;script&gt;alert("xss");&lt;/script&gt;','a' ]

** Object **
console.log(JsonScrubber({
    "entry":[{
       "comments":"<script>alert('xss');</script>Test REST API Comments.",
       "color":"color10",
       "@name": {
           "first": [{
               "second": "<alert>rn_tag</alert>"
           }]
       }
    }]
 }));
 
 // {
    "entry":[{
        "comments":"&lt;script&gt;alert('xss');&lt;/script&gt;Test REST API Comments.",
        "color":"color10",
        "@name": {
            "first": [{
                "second": "&lt;alert&gt;rn_tag&lt;/alert&gt;"
            }]
        }
     }]
}

Keywords

FAQs

Last updated on 20 Sep 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc