{"name":"xss-filters","version":"1.2.7","licenses":[{"type":"BSD","url":"https://github.com/yahoo/xss-filters/blob/master/LICENSE"}],"description":"Secure XSS Filters - Just sufficient output filtering to prevent XSS!","author":{"name":"Adonis Fung","email":"adon@yahoo-inc.com"},"contributors":[{"name":"Adonis Fung","email":"adon@yahoo-inc.com"},{"name":"Nera Liu","email":"neraliu@gmail.com"},{"name":"Albert Yu","email":"yukinying@gmail.com"}],"main":"src/xss-filters.js","scripts":{"test":"grunt test","hint":"grunt jshint","docs":"grunt docs","clean":"grunt clean","build":"grunt"},"keywords":["xss","output filter","sanitize","sanitise","escape","encode","filter","context-aware","context-sensitive","security","yahoo"],"devDependencies":{"expect.js":"^0.3.1","grunt":"^1.0.1","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-jshint":"^1.0.0","grunt-contrib-uglify":"^2.0.0","grunt-jsdoc":"^2.1.0","grunt-karma":"^2.0.0","grunt-mocha-istanbul":"^5.0.2","ink-docstrap":"^1.3.0","istanbul":"^0.4.5","karma":"^1.3.0","karma-chrome-launcher":"^2.0.0","karma-firefox-launcher":"^1.0.0","karma-ie-launcher":"^1.0.0","karma-mocha":"^1.1.1","karma-sauce-launcher":"^1.0.0","mocha":"^3.0.2"},"bugs":{"url":"https://github.com/yahoo/xss-filters/issues"},"homepage":"https://github.com/yahoo/xss-filters","repository":{"type":"git","url":"git+https://github.com/yahoo/xss-filters.git"},"gitHead":"5174da0a282f5fbd9289be1d0dd217f874a9f05c","_id":"xss-filters@1.2.7","_shasum":"59fa1de201f36f2f3470dcac5f58ccc2830b0a9a","_from":".","_npmVersion":"3.8.9","_nodeVersion":"6.2.0","_npmUser":{"name":"adon","email":"adon@yahoo-inc.com"},"dist":{"shasum":"59fa1de201f36f2f3470dcac5f58ccc2830b0a9a","tarball":"http://registry-npm.ywwl.com/xss-filters/download/xss-filters-1.2.7.tgz","integrity":"sha512-KzcmYT/f+YzcYrYRqw6mXxd25BEZCxBQnf+uXTopQDIhrmiaLwO+f+yLsIvvNlPhYvgff8g3igqrBxYh9k8NbQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB0C1pauICqpA6bs/5YKQf3dRDMFoNUtSLa9JC/lCOr+AiEAoHZcO+gcn4TjrxVNHUyM2D6p2rNZw3hQJaysZ/xeOVs="}],"size":45175,"noattachment":false,"key":"/xss-filters/-/xss-filters-1.2.7.tgz"},"maintainers":[{"name":"adon","email":"adon@yahoo-inc.com"},{"name":"neraliu","email":"neraliu@gmail.com"},{"name":"yukinying","email":"yukinying@gmail.com"},{"name":"davglass","email":"davglass@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/xss-filters-1.2.7.tgz_1473710461257_0.6442861577961594"},"directories":{},"readme":"Secure XSS Filters\n=================\n*Just sufficient* output filtering to prevent XSS!\n\n[![npm version][npm-badge]][npm]\n[![dependency status][dep-badge]][dep-status]\n[![Build Status](https://travis-ci.org/yahoo/xss-filters.svg?branch=master)](https://travis-ci.org/yahoo/xss-filters)\n\n[npm]: https://www.npmjs.org/package/xss-filters\n[npm-badge]: https://img.shields.io/npm/v/xss-filters.svg?style=flat-square\n[dep-status]: https://david-dm.org/yahoo/xss-filters\n[dep-badge]: https://img.shields.io/david/yahoo/xss-filters.svg?style=flat-square\n\n## Goals\n\n- **More Secure.** Context-dependent output filters that are developer-friendly. It is safe to apply these filters like so: \n\n  `document.write(\"<a href=\" + xssFilters.uriInUnQuotedAttr(url) + \">\" + xssFilters.uriInHTMLData(url) + \"</a>\");`\n\n  In this example, the traditional wisdom of blindly escaping some special html entity characters (`&` `<` `>` `'` `\"` `` ` ``) would not stop XSS (e.g., when `url` is equal to `javascript:alert(1)` or ` onclick=alert(1)`).\n\n- **Faster with Just Sufficient Encoding.** Encode the *minimal* set of characters to thwart JavaScript executions, thus preventing XSS attacks while keeping most characters intact. Compared to the traditional blindly escape filter, our filters are [up to two times faster](http://jsperf.com/context-sensitive-vs-blindly-escape), and there is no more double-encoding problems such as '&amp;amp;lt;'!!\n\n  ![alt Visualizing the concept of just sufficient encoding](https://ierg4210.github.io/web/images/xss-filters/xss-filters.png)\n  Figure 1. \"Just sufficient\" encoding based on the HTML5 spec.\n\n## Design\n- **Automation.** Nothing can be better than applying context-sensitive output escaping automatically. Integration with Handlebars template engine is now available. Check out [express-secure-handlebars](https://www.npmjs.com/package/express-secure-handlebars) for server-side use, or [secure-handlebars](https://www.npmjs.com/package/secure-handlebars) for client-side use.\n- **Standards Compliant.** The XSS filters are designed primarily based on the modern [HTML 5 Specification](https://html.spec.whatwg.org/multipage/syntax.html#syntax). The principle is to escape characters specific to each non-scriptable output context. Hence, untrusted inputs, once sanitized by context-sensitive escaping, cannot break out from the containing context. This approach stops malicious inputs from being executed as scripts, and also prevents the age-old problem of over/double-encoding.\n- **Carefully Designed.** Every filter is heavily scrutinized by Yahoo Security Engineers. The specific sets of characters that require encoding are minimized to preserve usability to the greatest extent possible.\n\n## Quick Start\n\n### Server-side (nodejs)\n\nInstall the [xss-filters npm](https://www.npmjs.com/package/xss-filters), and include it as a dependency for your project.\n```sh\nnpm install xss-filters --save\n```\n\nRequire *xss-filters*, and you may use it with your favorite template engine. Or just use it directly:\n\n```javascript\nvar express = require('express');\nvar app = express();\nvar xssFilters = require('xss-filters');\n\napp.get('/', function(req, res){\n  var firstname = req.query.firstname; //an untrusted input collected from user\n  res.send('<h1> Hello, ' + xssFilters.inHTMLData(firstname) + '!</h1>');\n});\n\napp.listen(3000);\n```\n\n### Client-side (browser)\n\nSimply download the latest minified version from the [`dist/`](./dist) folder OR from the <a href=\"https://cdn.rawgit.com/yahoo/xss-filters/master/dist/xss-filters.js\">CDN</a>. Embed it in your HTML file, and all filters are available in a global object called `xssFilters`.\n\n```html\n<!doctype html><!-- You need HTML 5 mode for browser -->\n...\n<script src=\"dist/xss-filters.min.js\"></script>\n<script>\nvar firstname = \"...\"; //an untrusted input collected from user\ndocument.write('<h1> Hello, ' + xssFilters.inHTMLData(firstname) + '!</h1>')\n</script>\n```\n\nAPI Documentations\n-------\n\n### WARNINGS\n\n(1) Filters **MUST ONLY** be applied to UTF-8-encoded documents.\n\n(2) **DON'T** apply any filters inside any scriptable contexts, i.e., `<script>`, `<style>`, `<object>`, `<embed>`, and `<svg>` tags as well as `style=\"\"` and `onXXX=\"\"` (e.g., `onclick`) attributes. It is **unsafe** to permit untrusted input inside a scriptable context. \n\nA workaround, if you need to include data for JS, is to use:\n```html\n<input id=\"strJS\" value=\"{{{inDoubleQuotedAttr data}}}\">\n```\nand retrieve your data with `document.getElementById('strJS').value`.\n\n### The API\n\nThere are five context-sensitive filters for generic input:\n - `<div>` `{{{inHTMLData data}}}` `</div>`\n - `<!--` `{{{inHTMLComment comment}}}` `-->`\n - `<input value='` `{{{inSingleQuotedAttr value}}}` `'/>`\n - `<input value=\"` `{{{inDoubleQuotedAttr value}}}` `\"/>`\n - `<input value=` `{{{inUnQuotedAttr value}}}` `/>`\n\n> Here we use {{{ }}} to indicate output expression to ease illustrations\n\n**Whenever possible, apply the most specific filter** that describes your context and data:\n\n| Input\\Context | HTMLData | HTMLComment | SingleQuotedAttr | DoubleQuotedAttr | UnQuotedAttr |\n| -------- | -------- | -------- | -------- | -------- | -------- |\n| Full URI | uriInHTMLData() | uriInHTMLComment() | uriInSingleQuotedAttr() | uriInDoubleQuotedAttr() | uriInUnQuotedAttr() |\n| URI Path | uriPathInHTMLData() | uriPathInHTMLComment() | uriPathInSingleQuotedAttr() | uriPathInDoubleQuotedAttr() | uriPathInUnQuotedAttr() |\n| URI Query | uriQueryInHTMLData() | uriQueryInHTMLComment() | uriQueryInSingleQuotedAttr() | uriQueryInDoubleQuotedAttr() | uriQueryInUnQuotedAttr() |\n| URI Component | uriComponentInHTMLData() | uriComponentInHTMLComment() | uriComponentInSingleQuotedAttr() | uriComponentInDoubleQuotedAttr() | uriComponentInUnQuotedAttr() |\n| URI Fragment | uriFragmentInHTMLData() | uriFragmentInHTMLComment() | uriFragmentInSingleQuotedAttr() | uriFragmentInDoubleQuotedAttr() | uriFragmentInUnQuotedAttr() |\n\nCheck out the [documentations](../../wiki) for more details.\n\n\n\nContributing\n-------\nTo contribute, make changes in [`src/`](./src) and [`tests/`](./tests), and then do:\n```sh\nnpm test              # run the tests\nnpm run-script build  # build the minified version for client-side use\nnpm run-script docs   # build the docs\n```\n\n\nLicense\n-------\n\nThis software is free to use under the Yahoo BSD license.\nSee the [LICENSE file](./LICENSE) for license text and copyright information.\n","publish_time":1473710464388,"_cnpm_publish_time":1473710464388,"dist-tags":{"latest":"1.2.7"}}