Skip to content

Commit 1790273

Browse files
committed
Initial commit
0 parents  commit 1790273

16 files changed

+1586
-0
lines changed

.editorconfig

+15
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

+4
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

+6
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

+6
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

+39
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

+13
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

+25
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

+22
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

+35
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

+6
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+
==================

index.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @author Titus Wormer
3+
* @copyright 2015 Titus Wormer
4+
* @license MIT
5+
* @module hdast:sanitize
6+
* @fileoverview Sanitize HAST.
7+
*/
8+
9+
'use strict';
10+
11+
/* eslint-env commonjs */
12+
13+
/* Expose. */
14+
module.exports = require('./lib/index');

lib/github.json

+200
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
{
2+
"strip": [
3+
"script"
4+
],
5+
"clobberPrefix": "user-content-",
6+
"clobber": [
7+
"name",
8+
"id"
9+
],
10+
"ancestors": {
11+
"li": [
12+
"ol",
13+
"ul"
14+
],
15+
"tbody": [
16+
"table"
17+
],
18+
"tfoot": [
19+
"table"
20+
],
21+
"thead": [
22+
"table"
23+
],
24+
"td": [
25+
"table"
26+
],
27+
"th": [
28+
"table"
29+
],
30+
"tr": [
31+
"table"
32+
]
33+
},
34+
"protocols": {
35+
"href": [
36+
"http",
37+
"https",
38+
"mailto"
39+
],
40+
"cite": [
41+
"http",
42+
"https"
43+
],
44+
"src": [
45+
"http",
46+
"https"
47+
],
48+
"longDesc": [
49+
"http",
50+
"https"
51+
]
52+
},
53+
"tagNames": [
54+
"h1",
55+
"h2",
56+
"h3",
57+
"h4",
58+
"h5",
59+
"h6",
60+
"h7",
61+
"h8",
62+
"br",
63+
"b",
64+
"i",
65+
"strong",
66+
"em",
67+
"a",
68+
"pre",
69+
"code",
70+
"img",
71+
"tt",
72+
"div",
73+
"ins",
74+
"del",
75+
"sup",
76+
"sub",
77+
"p",
78+
"ol",
79+
"ul",
80+
"table",
81+
"thead",
82+
"tbody",
83+
"tfoot",
84+
"blockquote",
85+
"dl",
86+
"dt",
87+
"dd",
88+
"kbd",
89+
"q",
90+
"samp",
91+
"var",
92+
"hr",
93+
"ruby",
94+
"rt",
95+
"rp",
96+
"li",
97+
"tr",
98+
"td",
99+
"th",
100+
"s",
101+
"strike",
102+
"summary",
103+
"details"
104+
],
105+
"attributes": {
106+
"a": [
107+
"href"
108+
],
109+
"img": [
110+
"src",
111+
"longDesc"
112+
],
113+
"div": [
114+
"itemScope",
115+
"itemType"
116+
],
117+
"blockquote": [
118+
"cite"
119+
],
120+
"del": [
121+
"cite"
122+
],
123+
"ins": [
124+
"cite"
125+
],
126+
"q": [
127+
"cite"
128+
],
129+
"*": [
130+
"abbr",
131+
"accept",
132+
"acceptCharset",
133+
"accessKey",
134+
"action",
135+
"align",
136+
"alt",
137+
"axis",
138+
"border",
139+
"cellPadding",
140+
"cellSpacing",
141+
"char",
142+
"charoff",
143+
"charSet",
144+
"checked",
145+
"clear",
146+
"cols",
147+
"colSpan",
148+
"color",
149+
"compact",
150+
"coords",
151+
"dateTime",
152+
"dir",
153+
"disabled",
154+
"encType",
155+
"htmlFor",
156+
"frame",
157+
"headers",
158+
"height",
159+
"hrefLang",
160+
"hspace",
161+
"isMap",
162+
"id",
163+
"label",
164+
"lang",
165+
"maxLength",
166+
"media",
167+
"method",
168+
"multiple",
169+
"name",
170+
"nohref",
171+
"noshade",
172+
"nowrap",
173+
"open",
174+
"prompt",
175+
"readOnly",
176+
"rel",
177+
"rev",
178+
"rows",
179+
"rowSpan",
180+
"rules",
181+
"scope",
182+
"selected",
183+
"shape",
184+
"size",
185+
"span",
186+
"start",
187+
"summary",
188+
"tabIndex",
189+
"target",
190+
"title",
191+
"type",
192+
"useMap",
193+
"valign",
194+
"value",
195+
"vspace",
196+
"width",
197+
"itemProp"
198+
]
199+
}
200+
}

0 commit comments

Comments
 (0)