Skip to content

Commit 1790273

Browse files
committed
Initial commit
0 parents  commit 1790273

16 files changed

+1586
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.{json,remarkrc,eslintrc,sh}]
12+
indent_size = 2
13+
14+
[*.md]
15+
trim_trailing_whitespace = false

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
coverage/
2+
example.js
3+
hast-util-sanitize.js
4+
hast-util-sanitize.min.js

.eslintrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "eslint:recommended",
3+
"rules": {
4+
"quotes": [2, "single"]
5+
}
6+
}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
*.log
3+
coverage/
4+
node_modules/
5+
hast-util-sanitize.js
6+
hast-util-sanitize.min.js

.jscs.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"excludeFiles": [
3+
"coverage/",
4+
"node_modules/",
5+
"hast-util-sanitize.js",
6+
"hast-util-sanitize.min.js"
7+
],
8+
"preset": "crockford",
9+
"requireMultipleVarDecl": false,
10+
"disallowDanglingUnderscores": false,
11+
"disallowQuotedKeysInObjects": {"allExcept": ["reserved"]},
12+
"disallowKeywords": [
13+
"with"
14+
],
15+
"maximumLineLength": {
16+
"value": 79,
17+
"allExcept": [
18+
"regex",
19+
"urlComments"
20+
]
21+
},
22+
"jsDoc": {
23+
"checkAnnotations": "jsdoc3",
24+
"checkParamExistence": true,
25+
"checkParamNames": true,
26+
"checkRedundantAccess": true,
27+
"checkRedundantParams": true,
28+
"checkRedundantReturns": true,
29+
"checkReturnTypes": true,
30+
"checkTypes": "strictNativeCase",
31+
"enforceExistence": true,
32+
"requireHyphenBeforeDescription": true,
33+
"requireNewlineAfterDescription": true,
34+
"requireParamDescription": true,
35+
"requireParamTypes": true,
36+
"requireReturnDescription": true,
37+
"requireReturnTypes": true
38+
}
39+
}

.remarkrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"output": true,
3+
"plugins": [
4+
"comment-config",
5+
"lint",
6+
"github",
7+
"validate-links",
8+
"usage"
9+
],
10+
"settings": {
11+
"bullet": "*"
12+
}
13+
}

.travis.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
language: node_js
2+
node_js:
3+
- '0.11'
4+
- '0.12'
5+
- '4.0'
6+
- '5.0'
7+
- '6.0'
8+
after_success: bash <(curl -s https://codecov.io/bash)
9+
deploy:
10+
- provider: npm
11+
12+
api_key:
13+
secure: v7ILvzNZ4R2M4C94inlm2qtiiocsylnHEXZYaWT2RiLZXWNirrDgx71jA/LhKcEdajnwyQHSEzUKj5A8ik2E0gHiUElF2TGlSlLAQMrunNlnIExO5ENYdGFE62N7G5UeQUdmIzLH+YpQGUQMZFfTqgl6k3e+TDhvTNrFqoHAzC0HkugrGiIIvVwvwhvZ21U+U+YCkkckFwCdtEciPAAZ4E8XeSoHk0ItIVWm3ua4KTZ/Wz3/nlvK0WgmuKndDWqtMvZAEfaxNRsTJk6i/95DWfsycCvQXVhAJ0ehSDK6SgvVrE6i+eiBUowDsDdc+alDfJ0MMKE8hj+kRxaYEo5t64rqX+o8zatQxbcEozfx2D9OTWYjfihG7rFEEnBnZiLKcX6LqioTspaTna/vZjV1HmfgQXXvEsLYkA7OSUZCvm/XtGiM1Zamkl9O1zRWQvudHLsnrgFfQJMdL3aHcpGBfIiibP+EJHoBJprQN5sVyzdJyp8tzYMobPua+jhMrvKgaNPhfuZ+wmWQyU3ihI540feEPmZIg+YfzNLpp75i5gHBXIuSmZJ0AjVWhanV5NNRhDgh/AkldUnQOYeZXxiqcUAfi5anVuWwNvpq2xerLX2fJVbj09EeoXlN7w9S1pTemUlBhr+mDGudfLposXIRDcr7FhI/pcPKQX3tyQQ//hs=
14+
on:
15+
tags: true
16+
node: '5.0'
17+
- provider: releases
18+
api_key:
19+
secure: jL05HgVf3iCKoMo+Gr623BQEhex5HF63ifPVkOprWjP4xXXh5ZA8b5NOMMN0lAyvOTRjYpRMzqzwt9HATZD1FSbiIzpQ4Q2VPwnkDC0RGm22/QGkOLj/HGg+gdhzqzkR2CymfJOPLvCPatr37GBBB1rvM3kZ9cOHA1m91ZbKOKcTM/DcRKNoveFDb/Naz8AsLmBaiMSLPNSPV8lkcDbBTBatP/6xzpa1Y++BEAkTizaXGJD5dhs7kBsbJ27+MPwHieqUfVx5k2yIGA/TKBnEPFkToq6EvTzAIn3QXEO2r6WBwAVN3cCRq8b0RnRI28JVoNuvpCji5Oa0vgdOhlRCZKHY8bwD+tyQ+tCPb67GnOIWB0glad8RCtEZyjQDCwBaqqVV+Ab/qiUAv9V5dTU5HyLewijHOXcHkEtVJ/XcwJaJQOPnEDXsukrhxXI3h84FiL3d+32IOCkrOHmX9ISPaC1y6hllbqJ6Fqiqmn+fJfJyaUluXiqNmDgF9FRc+PcmY89EeHlbsjH9WfWCH8X7ZGoRiHUSSw96CY1XwXsOqJO50CVN0RtG32yoqALbhHQFuU1+UocHvskC9v8hXPX6l1lPfYU+IYSleO59nq+/sQ9r5Nr9ybF1ybLtzk/N7yL62+wxXazo2jgJM3dpAjsckTPmnz5iokKZ32QDJNSSU10=
20+
file:
21+
- "hast-util-sanitize.js"
22+
- "hast-util-sanitize.min.js"
23+
on:
24+
tags: true
25+
node: '6.0'

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2016 Titus Wormer <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
'Software'), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

example.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Dependencies:
2+
var h = require('hastscript');
3+
var u = require('unist-builder');
4+
var sanitize = require('./index.js');
5+
var toHTML = require('hast-util-to-html');
6+
7+
// Transform:
8+
var tree = h('div', {
9+
onmouseover: 'alert("alpha")'
10+
}, [
11+
h('a', {
12+
href: 'jAva script:alert("bravo")',
13+
onclick: 'alert("charlie")'
14+
}, 'delta'),
15+
u('text', '\n'),
16+
h('script', 'alert("charlie")'),
17+
u('text', '\n'),
18+
h('img', {src: 'x', onerror: 'alert("delta")'}),
19+
u('text', '\n'),
20+
h('iframe', {src: 'javascript:alert("echo")'}),
21+
u('text', '\n'),
22+
h('math', h('mi', {
23+
'xlink:href': 'data:x,<script>alert("foxtrot")</script>'
24+
}))
25+
]);
26+
27+
// Compile:
28+
var unsanitized = toHTML(tree);
29+
var sanitized = toHTML(sanitize(tree));
30+
31+
// Unsanitized:
32+
console.log('html', unsanitized);
33+
34+
// Sanitized:
35+
console.log('html', sanitized);

history.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!--remark setext-->
2+
3+
<!--lint disable no-multiple-toplevel-headings -->
4+
5+
0.0.0 / 2016-06-18
6+
==================

0 commit comments

Comments
 (0)