Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xss-scrubber

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xss-scrubber

Scrubs xss content in a JavaScript object

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
49
increased by4.26%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 20 Sep 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc