rootaccessxvv-bbmarker 0.0.1-security → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rootaccessxvv-bbmarker might be problematic. Click here for more details.

Files changed (39) hide show
  1. package/README.md +13 -3
  2. package/index.js +1 -0
  3. package/package.json +18 -6
  4. package/sim/node_modules/.bin/xss +16 -0
  5. package/sim/node_modules/.bin/xss.cmd +17 -0
  6. package/sim/node_modules/.bin/xss.ps1 +28 -0
  7. package/sim/node_modules/.package-lock.json +36 -0
  8. package/sim/node_modules/commander/CHANGELOG.md +419 -0
  9. package/sim/node_modules/commander/LICENSE +22 -0
  10. package/sim/node_modules/commander/Readme.md +428 -0
  11. package/sim/node_modules/commander/index.js +1224 -0
  12. package/sim/node_modules/commander/package.json +38 -0
  13. package/sim/node_modules/commander/typings/index.d.ts +310 -0
  14. package/sim/node_modules/cssfilter/LICENSE +22 -0
  15. package/sim/node_modules/cssfilter/README.md +86 -0
  16. package/sim/node_modules/cssfilter/lib/css.js +110 -0
  17. package/sim/node_modules/cssfilter/lib/default.js +398 -0
  18. package/sim/node_modules/cssfilter/lib/index.js +32 -0
  19. package/sim/node_modules/cssfilter/lib/parser.js +74 -0
  20. package/sim/node_modules/cssfilter/lib/util.js +35 -0
  21. package/sim/node_modules/cssfilter/package.json +49 -0
  22. package/sim/node_modules/xss/CHANGELOG.md +24 -0
  23. package/sim/node_modules/xss/LICENSE +23 -0
  24. package/sim/node_modules/xss/README.md +505 -0
  25. package/sim/node_modules/xss/README.zh.md +491 -0
  26. package/sim/node_modules/xss/bin/xss +67 -0
  27. package/sim/node_modules/xss/dist/test.html +15 -0
  28. package/sim/node_modules/xss/dist/xss.js +1665 -0
  29. package/sim/node_modules/xss/dist/xss.min.js +1 -0
  30. package/sim/node_modules/xss/lib/cli.js +45 -0
  31. package/sim/node_modules/xss/lib/default.js +459 -0
  32. package/sim/node_modules/xss/lib/index.js +44 -0
  33. package/sim/node_modules/xss/lib/parser.js +247 -0
  34. package/sim/node_modules/xss/lib/util.js +34 -0
  35. package/sim/node_modules/xss/lib/xss.js +211 -0
  36. package/sim/node_modules/xss/package.json +63 -0
  37. package/sim/node_modules/xss/typings/xss.d.ts +202 -0
  38. package/sim/package-lock.json +44 -0
  39. package/sim/package.json +16 -0
@@ -0,0 +1,1665 @@
1
+ (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2
+ /**
3
+ * default settings
4
+ *
5
+ * @author Zongmin Lei<leizongmin@gmail.com>
6
+ */
7
+
8
+ var FilterCSS = require("cssfilter").FilterCSS;
9
+ var getDefaultCSSWhiteList = require("cssfilter").getDefaultWhiteList;
10
+ var _ = require("./util");
11
+
12
+ function getDefaultWhiteList() {
13
+ return {
14
+ a: ["target", "href", "title"],
15
+ abbr: ["title"],
16
+ address: [],
17
+ area: ["shape", "coords", "href", "alt"],
18
+ article: [],
19
+ aside: [],
20
+ audio: [
21
+ "autoplay",
22
+ "controls",
23
+ "crossorigin",
24
+ "loop",
25
+ "muted",
26
+ "preload",
27
+ "src",
28
+ ],
29
+ b: [],
30
+ bdi: ["dir"],
31
+ bdo: ["dir"],
32
+ big: [],
33
+ blockquote: ["cite"],
34
+ br: [],
35
+ caption: [],
36
+ center: [],
37
+ cite: [],
38
+ code: [],
39
+ col: ["align", "valign", "span", "width"],
40
+ colgroup: ["align", "valign", "span", "width"],
41
+ dd: [],
42
+ del: ["datetime"],
43
+ details: ["open"],
44
+ div: [],
45
+ dl: [],
46
+ dt: [],
47
+ em: [],
48
+ figcaption: [],
49
+ figure: [],
50
+ font: ["color", "size", "face"],
51
+ footer: [],
52
+ h1: [],
53
+ h2: [],
54
+ h3: [],
55
+ h4: [],
56
+ h5: [],
57
+ h6: [],
58
+ header: [],
59
+ hr: [],
60
+ i: [],
61
+ img: ["src", "alt", "title", "width", "height"],
62
+ ins: ["datetime"],
63
+ li: [],
64
+ mark: [],
65
+ nav: [],
66
+ ol: [],
67
+ p: [],
68
+ pre: [],
69
+ s: [],
70
+ section: [],
71
+ small: [],
72
+ span: [],
73
+ sub: [],
74
+ summary: [],
75
+ sup: [],
76
+ strong: [],
77
+ strike: [],
78
+ table: ["width", "border", "align", "valign"],
79
+ tbody: ["align", "valign"],
80
+ td: ["width", "rowspan", "colspan", "align", "valign"],
81
+ tfoot: ["align", "valign"],
82
+ th: ["width", "rowspan", "colspan", "align", "valign"],
83
+ thead: ["align", "valign"],
84
+ tr: ["rowspan", "align", "valign"],
85
+ tt: [],
86
+ u: [],
87
+ ul: [],
88
+ video: [
89
+ "autoplay",
90
+ "controls",
91
+ "crossorigin",
92
+ "loop",
93
+ "muted",
94
+ "playsinline",
95
+ "poster",
96
+ "preload",
97
+ "src",
98
+ "height",
99
+ "width",
100
+ ],
101
+ };
102
+ }
103
+
104
+ var defaultCSSFilter = new FilterCSS();
105
+
106
+ /**
107
+ * default onTag function
108
+ *
109
+ * @param {String} tag
110
+ * @param {String} html
111
+ * @param {Object} options
112
+ * @return {String}
113
+ */
114
+ function onTag(tag, html, options) {
115
+ // do nothing
116
+ }
117
+
118
+ /**
119
+ * default onIgnoreTag function
120
+ *
121
+ * @param {String} tag
122
+ * @param {String} html
123
+ * @param {Object} options
124
+ * @return {String}
125
+ */
126
+ function onIgnoreTag(tag, html, options) {
127
+ // do nothing
128
+ }
129
+
130
+ /**
131
+ * default onTagAttr function
132
+ *
133
+ * @param {String} tag
134
+ * @param {String} name
135
+ * @param {String} value
136
+ * @return {String}
137
+ */
138
+ function onTagAttr(tag, name, value) {
139
+ // do nothing
140
+ }
141
+
142
+ /**
143
+ * default onIgnoreTagAttr function
144
+ *
145
+ * @param {String} tag
146
+ * @param {String} name
147
+ * @param {String} value
148
+ * @return {String}
149
+ */
150
+ function onIgnoreTagAttr(tag, name, value) {
151
+ // do nothing
152
+ }
153
+
154
+ /**
155
+ * default escapeHtml function
156
+ *
157
+ * @param {String} html
158
+ */
159
+ function escapeHtml(html) {
160
+ return html.replace(REGEXP_LT, "&lt;").replace(REGEXP_GT, "&gt;");
161
+ }
162
+
163
+ /**
164
+ * default safeAttrValue function
165
+ *
166
+ * @param {String} tag
167
+ * @param {String} name
168
+ * @param {String} value
169
+ * @param {Object} cssFilter
170
+ * @return {String}
171
+ */
172
+ function safeAttrValue(tag, name, value, cssFilter) {
173
+ // unescape attribute value firstly
174
+ value = friendlyAttrValue(value);
175
+
176
+ if (name === "href" || name === "src") {
177
+ // filter `href` and `src` attribute
178
+ // only allow the value that starts with `http://` | `https://` | `mailto:` | `/` | `#`
179
+ value = _.trim(value);
180
+ if (value === "#") return "#";
181
+ if (
182
+ !(
183
+ value.substr(0, 7) === "http://" ||
184
+ value.substr(0, 8) === "https://" ||
185
+ value.substr(0, 7) === "mailto:" ||
186
+ value.substr(0, 4) === "tel:" ||
187
+ value.substr(0, 11) === "data:image/" ||
188
+ value.substr(0, 6) === "ftp://" ||
189
+ value.substr(0, 2) === "./" ||
190
+ value.substr(0, 3) === "../" ||
191
+ value[0] === "#" ||
192
+ value[0] === "/"
193
+ )
194
+ ) {
195
+ return "";
196
+ }
197
+ } else if (name === "background") {
198
+ // filter `background` attribute (maybe no use)
199
+ // `javascript:`
200
+ REGEXP_DEFAULT_ON_TAG_ATTR_4.lastIndex = 0;
201
+ if (REGEXP_DEFAULT_ON_TAG_ATTR_4.test(value)) {
202
+ return "";
203
+ }
204
+ } else if (name === "style") {
205
+ // `expression()`
206
+ REGEXP_DEFAULT_ON_TAG_ATTR_7.lastIndex = 0;
207
+ if (REGEXP_DEFAULT_ON_TAG_ATTR_7.test(value)) {
208
+ return "";
209
+ }
210
+ // `url()`
211
+ REGEXP_DEFAULT_ON_TAG_ATTR_8.lastIndex = 0;
212
+ if (REGEXP_DEFAULT_ON_TAG_ATTR_8.test(value)) {
213
+ REGEXP_DEFAULT_ON_TAG_ATTR_4.lastIndex = 0;
214
+ if (REGEXP_DEFAULT_ON_TAG_ATTR_4.test(value)) {
215
+ return "";
216
+ }
217
+ }
218
+ if (cssFilter !== false) {
219
+ cssFilter = cssFilter || defaultCSSFilter;
220
+ value = cssFilter.process(value);
221
+ }
222
+ }
223
+
224
+ // escape `<>"` before returns
225
+ value = escapeAttrValue(value);
226
+ return value;
227
+ }
228
+
229
+ // RegExp list
230
+ var REGEXP_LT = /</g;
231
+ var REGEXP_GT = />/g;
232
+ var REGEXP_QUOTE = /"/g;
233
+ var REGEXP_QUOTE_2 = /&quot;/g;
234
+ var REGEXP_ATTR_VALUE_1 = /&#([a-zA-Z0-9]*);?/gim;
235
+ var REGEXP_ATTR_VALUE_COLON = /&colon;?/gim;
236
+ var REGEXP_ATTR_VALUE_NEWLINE = /&newline;?/gim;
237
+ var REGEXP_DEFAULT_ON_TAG_ATTR_3 = /\/\*|\*\//gm;
238
+ var REGEXP_DEFAULT_ON_TAG_ATTR_4 =
239
+ /((j\s*a\s*v\s*a|v\s*b|l\s*i\s*v\s*e)\s*s\s*c\s*r\s*i\s*p\s*t\s*|m\s*o\s*c\s*h\s*a)\:/gi;
240
+ var REGEXP_DEFAULT_ON_TAG_ATTR_5 = /^[\s"'`]*(d\s*a\s*t\s*a\s*)\:/gi;
241
+ var REGEXP_DEFAULT_ON_TAG_ATTR_6 = /^[\s"'`]*(d\s*a\s*t\s*a\s*)\:\s*image\//gi;
242
+ var REGEXP_DEFAULT_ON_TAG_ATTR_7 =
243
+ /e\s*x\s*p\s*r\s*e\s*s\s*s\s*i\s*o\s*n\s*\(.*/gi;
244
+ var REGEXP_DEFAULT_ON_TAG_ATTR_8 = /u\s*r\s*l\s*\(.*/gi;
245
+
246
+ /**
247
+ * escape double quote
248
+ *
249
+ * @param {String} str
250
+ * @return {String} str
251
+ */
252
+ function escapeQuote(str) {
253
+ return str.replace(REGEXP_QUOTE, "&quot;");
254
+ }
255
+
256
+ /**
257
+ * unescape double quote
258
+ *
259
+ * @param {String} str
260
+ * @return {String} str
261
+ */
262
+ function unescapeQuote(str) {
263
+ return str.replace(REGEXP_QUOTE_2, '"');
264
+ }
265
+
266
+ /**
267
+ * escape html entities
268
+ *
269
+ * @param {String} str
270
+ * @return {String}
271
+ */
272
+ function escapeHtmlEntities(str) {
273
+ return str.replace(REGEXP_ATTR_VALUE_1, function replaceUnicode(str, code) {
274
+ return code[0] === "x" || code[0] === "X"
275
+ ? String.fromCharCode(parseInt(code.substr(1), 16))
276
+ : String.fromCharCode(parseInt(code, 10));
277
+ });
278
+ }
279
+
280
+ /**
281
+ * escape html5 new danger entities
282
+ *
283
+ * @param {String} str
284
+ * @return {String}
285
+ */
286
+ function escapeDangerHtml5Entities(str) {
287
+ return str
288
+ .replace(REGEXP_ATTR_VALUE_COLON, ":")
289
+ .replace(REGEXP_ATTR_VALUE_NEWLINE, " ");
290
+ }
291
+
292
+ /**
293
+ * clear nonprintable characters
294
+ *
295
+ * @param {String} str
296
+ * @return {String}
297
+ */
298
+ function clearNonPrintableCharacter(str) {
299
+ var str2 = "";
300
+ for (var i = 0, len = str.length; i < len; i++) {
301
+ str2 += str.charCodeAt(i) < 32 ? " " : str.charAt(i);
302
+ }
303
+ return _.trim(str2);
304
+ }
305
+
306
+ /**
307
+ * get friendly attribute value
308
+ *
309
+ * @param {String} str
310
+ * @return {String}
311
+ */
312
+ function friendlyAttrValue(str) {
313
+ str = unescapeQuote(str);
314
+ str = escapeHtmlEntities(str);
315
+ str = escapeDangerHtml5Entities(str);
316
+ str = clearNonPrintableCharacter(str);
317
+ return str;
318
+ }
319
+
320
+ /**
321
+ * unescape attribute value
322
+ *
323
+ * @param {String} str
324
+ * @return {String}
325
+ */
326
+ function escapeAttrValue(str) {
327
+ str = escapeQuote(str);
328
+ str = escapeHtml(str);
329
+ return str;
330
+ }
331
+
332
+ /**
333
+ * `onIgnoreTag` function for removing all the tags that are not in whitelist
334
+ */
335
+ function onIgnoreTagStripAll() {
336
+ return "";
337
+ }
338
+
339
+ /**
340
+ * remove tag body
341
+ * specify a `tags` list, if the tag is not in the `tags` list then process by the specify function (optional)
342
+ *
343
+ * @param {array} tags
344
+ * @param {function} next
345
+ */
346
+ function StripTagBody(tags, next) {
347
+ if (typeof next !== "function") {
348
+ next = function () {};
349
+ }
350
+
351
+ var isRemoveAllTag = !Array.isArray(tags);
352
+ function isRemoveTag(tag) {
353
+ if (isRemoveAllTag) return true;
354
+ return _.indexOf(tags, tag) !== -1;
355
+ }
356
+
357
+ var removeList = [];
358
+ var posStart = false;
359
+
360
+ return {
361
+ onIgnoreTag: function (tag, html, options) {
362
+ if (isRemoveTag(tag)) {
363
+ if (options.isClosing) {
364
+ var ret = "[/removed]";
365
+ var end = options.position + ret.length;
366
+ removeList.push([
367
+ posStart !== false ? posStart : options.position,
368
+ end,
369
+ ]);
370
+ posStart = false;
371
+ return ret;
372
+ } else {
373
+ if (!posStart) {
374
+ posStart = options.position;
375
+ }
376
+ return "[removed]";
377
+ }
378
+ } else {
379
+ return next(tag, html, options);
380
+ }
381
+ },
382
+ remove: function (html) {
383
+ var rethtml = "";
384
+ var lastPos = 0;
385
+ _.forEach(removeList, function (pos) {
386
+ rethtml += html.slice(lastPos, pos[0]);
387
+ lastPos = pos[1];
388
+ });
389
+ rethtml += html.slice(lastPos);
390
+ return rethtml;
391
+ },
392
+ };
393
+ }
394
+
395
+ /**
396
+ * remove html comments
397
+ *
398
+ * @param {String} html
399
+ * @return {String}
400
+ */
401
+ function stripCommentTag(html) {
402
+ var retHtml = "";
403
+ var lastPos = 0;
404
+ while (lastPos < html.length) {
405
+ var i = html.indexOf("<!--", lastPos);
406
+ if (i === -1) {
407
+ retHtml += html.slice(lastPos);
408
+ break;
409
+ }
410
+ retHtml += html.slice(lastPos, i);
411
+ var j = html.indexOf("-->", i);
412
+ if (j === -1) {
413
+ break;
414
+ }
415
+ lastPos = j + 3;
416
+ }
417
+ return retHtml;
418
+ }
419
+
420
+ /**
421
+ * remove invisible characters
422
+ *
423
+ * @param {String} html
424
+ * @return {String}
425
+ */
426
+ function stripBlankChar(html) {
427
+ var chars = html.split("");
428
+ chars = chars.filter(function (char) {
429
+ var c = char.charCodeAt(0);
430
+ if (c === 127) return false;
431
+ if (c <= 31) {
432
+ if (c === 10 || c === 13) return true;
433
+ return false;
434
+ }
435
+ return true;
436
+ });
437
+ return chars.join("");
438
+ }
439
+
440
+ exports.whiteList = getDefaultWhiteList();
441
+ exports.getDefaultWhiteList = getDefaultWhiteList;
442
+ exports.onTag = onTag;
443
+ exports.onIgnoreTag = onIgnoreTag;
444
+ exports.onTagAttr = onTagAttr;
445
+ exports.onIgnoreTagAttr = onIgnoreTagAttr;
446
+ exports.safeAttrValue = safeAttrValue;
447
+ exports.escapeHtml = escapeHtml;
448
+ exports.escapeQuote = escapeQuote;
449
+ exports.unescapeQuote = unescapeQuote;
450
+ exports.escapeHtmlEntities = escapeHtmlEntities;
451
+ exports.escapeDangerHtml5Entities = escapeDangerHtml5Entities;
452
+ exports.clearNonPrintableCharacter = clearNonPrintableCharacter;
453
+ exports.friendlyAttrValue = friendlyAttrValue;
454
+ exports.escapeAttrValue = escapeAttrValue;
455
+ exports.onIgnoreTagStripAll = onIgnoreTagStripAll;
456
+ exports.StripTagBody = StripTagBody;
457
+ exports.stripCommentTag = stripCommentTag;
458
+ exports.stripBlankChar = stripBlankChar;
459
+ exports.cssFilter = defaultCSSFilter;
460
+ exports.getDefaultCSSWhiteList = getDefaultCSSWhiteList;
461
+
462
+ },{"./util":4,"cssfilter":8}],2:[function(require,module,exports){
463
+ /**
464
+ * xss
465
+ *
466
+ * @author Zongmin Lei<leizongmin@gmail.com>
467
+ */
468
+
469
+ var DEFAULT = require("./default");
470
+ var parser = require("./parser");
471
+ var FilterXSS = require("./xss");
472
+
473
+ /**
474
+ * filter xss function
475
+ *
476
+ * @param {String} html
477
+ * @param {Object} options { whiteList, onTag, onTagAttr, onIgnoreTag, onIgnoreTagAttr, safeAttrValue, escapeHtml }
478
+ * @return {String}
479
+ */
480
+ function filterXSS(html, options) {
481
+ var xss = new FilterXSS(options);
482
+ return xss.process(html);
483
+ }
484
+
485
+ exports = module.exports = filterXSS;
486
+ exports.filterXSS = filterXSS;
487
+ exports.FilterXSS = FilterXSS;
488
+ for (var i in DEFAULT) exports[i] = DEFAULT[i];
489
+ for (var i in parser) exports[i] = parser[i];
490
+
491
+ // using `xss` on the browser, output `filterXSS` to the globals
492
+ if (typeof window !== "undefined") {
493
+ window.filterXSS = module.exports;
494
+ }
495
+
496
+ // using `xss` on the WebWorker, output `filterXSS` to the globals
497
+ function isWorkerEnv() {
498
+ return (
499
+ typeof self !== "undefined" &&
500
+ typeof DedicatedWorkerGlobalScope !== "undefined" &&
501
+ self instanceof DedicatedWorkerGlobalScope
502
+ );
503
+ }
504
+ if (isWorkerEnv()) {
505
+ self.filterXSS = module.exports;
506
+ }
507
+
508
+ },{"./default":1,"./parser":3,"./xss":5}],3:[function(require,module,exports){
509
+ /**
510
+ * Simple HTML Parser
511
+ *
512
+ * @author Zongmin Lei<leizongmin@gmail.com>
513
+ */
514
+
515
+ var _ = require("./util");
516
+
517
+ /**
518
+ * get tag name
519
+ *
520
+ * @param {String} html e.g. '<a hef="#">'
521
+ * @return {String}
522
+ */
523
+ function getTagName(html) {
524
+ var i = _.spaceIndex(html);
525
+ if (i === -1) {
526
+ var tagName = html.slice(1, -1);
527
+ } else {
528
+ var tagName = html.slice(1, i + 1);
529
+ }
530
+ tagName = _.trim(tagName).toLowerCase();
531
+ if (tagName.slice(0, 1) === "/") tagName = tagName.slice(1);
532
+ if (tagName.slice(-1) === "/") tagName = tagName.slice(0, -1);
533
+ return tagName;
534
+ }
535
+
536
+ /**
537
+ * is close tag?
538
+ *
539
+ * @param {String} html 如:'<a hef="#">'
540
+ * @return {Boolean}
541
+ */
542
+ function isClosing(html) {
543
+ return html.slice(0, 2) === "</";
544
+ }
545
+
546
+ /**
547
+ * parse input html and returns processed html
548
+ *
549
+ * @param {String} html
550
+ * @param {Function} onTag e.g. function (sourcePosition, position, tag, html, isClosing)
551
+ * @param {Function} escapeHtml
552
+ * @return {String}
553
+ */
554
+ function parseTag(html, onTag, escapeHtml) {
555
+ "use strict";
556
+
557
+ var rethtml = "";
558
+ var lastPos = 0;
559
+ var tagStart = false;
560
+ var quoteStart = false;
561
+ var currentPos = 0;
562
+ var len = html.length;
563
+ var currentTagName = "";
564
+ var currentHtml = "";
565
+
566
+ chariterator: for (currentPos = 0; currentPos < len; currentPos++) {
567
+ var c = html.charAt(currentPos);
568
+ if (tagStart === false) {
569
+ if (c === "<") {
570
+ tagStart = currentPos;
571
+ continue;
572
+ }
573
+ } else {
574
+ if (quoteStart === false) {
575
+ if (c === "<") {
576
+ rethtml += escapeHtml(html.slice(lastPos, currentPos));
577
+ tagStart = currentPos;
578
+ lastPos = currentPos;
579
+ continue;
580
+ }
581
+ if (c === ">") {
582
+ rethtml += escapeHtml(html.slice(lastPos, tagStart));
583
+ currentHtml = html.slice(tagStart, currentPos + 1);
584
+ currentTagName = getTagName(currentHtml);
585
+ rethtml += onTag(
586
+ tagStart,
587
+ rethtml.length,
588
+ currentTagName,
589
+ currentHtml,
590
+ isClosing(currentHtml)
591
+ );
592
+ lastPos = currentPos + 1;
593
+ tagStart = false;
594
+ continue;
595
+ }
596
+ if (c === '"' || c === "'") {
597
+ var i = 1;
598
+ var ic = html.charAt(currentPos - i);
599
+
600
+ while (ic.trim() === "" || ic === "=") {
601
+ if (ic === "=") {
602
+ quoteStart = c;
603
+ continue chariterator;
604
+ }
605
+ ic = html.charAt(currentPos - ++i);
606
+ }
607
+ }
608
+ } else {
609
+ if (c === quoteStart) {
610
+ quoteStart = false;
611
+ continue;
612
+ }
613
+ }
614
+ }
615
+ }
616
+ if (lastPos < html.length) {
617
+ rethtml += escapeHtml(html.substr(lastPos));
618
+ }
619
+
620
+ return rethtml;
621
+ }
622
+
623
+ var REGEXP_ILLEGAL_ATTR_NAME = /[^a-zA-Z0-9_:\.\-]/gim;
624
+
625
+ /**
626
+ * parse input attributes and returns processed attributes
627
+ *
628
+ * @param {String} html e.g. `href="#" target="_blank"`
629
+ * @param {Function} onAttr e.g. `function (name, value)`
630
+ * @return {String}
631
+ */
632
+ function parseAttr(html, onAttr) {
633
+ "use strict";
634
+
635
+ var lastPos = 0;
636
+ var retAttrs = [];
637
+ var tmpName = false;
638
+ var len = html.length;
639
+
640
+ function addAttr(name, value) {
641
+ name = _.trim(name);
642
+ name = name.replace(REGEXP_ILLEGAL_ATTR_NAME, "").toLowerCase();
643
+ if (name.length < 1) return;
644
+ var ret = onAttr(name, value || "");
645
+ if (ret) retAttrs.push(ret);
646
+ }
647
+
648
+ // 逐个分析字符
649
+ for (var i = 0; i < len; i++) {
650
+ var c = html.charAt(i);
651
+ var v, j;
652
+ if (tmpName === false && c === "=") {
653
+ tmpName = html.slice(lastPos, i);
654
+ lastPos = i + 1;
655
+ continue;
656
+ }
657
+ if (tmpName !== false) {
658
+ if (
659
+ i === lastPos &&
660
+ (c === '"' || c === "'") &&
661
+ html.charAt(i - 1) === "="
662
+ ) {
663
+ j = html.indexOf(c, i + 1);
664
+ if (j === -1) {
665
+ break;
666
+ } else {
667
+ v = _.trim(html.slice(lastPos + 1, j));
668
+ addAttr(tmpName, v);
669
+ tmpName = false;
670
+ i = j;
671
+ lastPos = i + 1;
672
+ continue;
673
+ }
674
+ }
675
+ }
676
+ if (/\s|\n|\t/.test(c)) {
677
+ html = html.replace(/\s|\n|\t/g, " ");
678
+ if (tmpName === false) {
679
+ j = findNextEqual(html, i);
680
+ if (j === -1) {
681
+ v = _.trim(html.slice(lastPos, i));
682
+ addAttr(v);
683
+ tmpName = false;
684
+ lastPos = i + 1;
685
+ continue;
686
+ } else {
687
+ i = j - 1;
688
+ continue;
689
+ }
690
+ } else {
691
+ j = findBeforeEqual(html, i - 1);
692
+ if (j === -1) {
693
+ v = _.trim(html.slice(lastPos, i));
694
+ v = stripQuoteWrap(v);
695
+ addAttr(tmpName, v);
696
+ tmpName = false;
697
+ lastPos = i + 1;
698
+ continue;
699
+ } else {
700
+ continue;
701
+ }
702
+ }
703
+ }
704
+ }
705
+
706
+ if (lastPos < html.length) {
707
+ if (tmpName === false) {
708
+ addAttr(html.slice(lastPos));
709
+ } else {
710
+ addAttr(tmpName, stripQuoteWrap(_.trim(html.slice(lastPos))));
711
+ }
712
+ }
713
+
714
+ return _.trim(retAttrs.join(" "));
715
+ }
716
+
717
+ function findNextEqual(str, i) {
718
+ for (; i < str.length; i++) {
719
+ var c = str[i];
720
+ if (c === " ") continue;
721
+ if (c === "=") return i;
722
+ return -1;
723
+ }
724
+ }
725
+
726
+ function findBeforeEqual(str, i) {
727
+ for (; i > 0; i--) {
728
+ var c = str[i];
729
+ if (c === " ") continue;
730
+ if (c === "=") return i;
731
+ return -1;
732
+ }
733
+ }
734
+
735
+ function isQuoteWrapString(text) {
736
+ if (
737
+ (text[0] === '"' && text[text.length - 1] === '"') ||
738
+ (text[0] === "'" && text[text.length - 1] === "'")
739
+ ) {
740
+ return true;
741
+ } else {
742
+ return false;
743
+ }
744
+ }
745
+
746
+ function stripQuoteWrap(text) {
747
+ if (isQuoteWrapString(text)) {
748
+ return text.substr(1, text.length - 2);
749
+ } else {
750
+ return text;
751
+ }
752
+ }
753
+
754
+ exports.parseTag = parseTag;
755
+ exports.parseAttr = parseAttr;
756
+
757
+ },{"./util":4}],4:[function(require,module,exports){
758
+ module.exports = {
759
+ indexOf: function (arr, item) {
760
+ var i, j;
761
+ if (Array.prototype.indexOf) {
762
+ return arr.indexOf(item);
763
+ }
764
+ for (i = 0, j = arr.length; i < j; i++) {
765
+ if (arr[i] === item) {
766
+ return i;
767
+ }
768
+ }
769
+ return -1;
770
+ },
771
+ forEach: function (arr, fn, scope) {
772
+ var i, j;
773
+ if (Array.prototype.forEach) {
774
+ return arr.forEach(fn, scope);
775
+ }
776
+ for (i = 0, j = arr.length; i < j; i++) {
777
+ fn.call(scope, arr[i], i, arr);
778
+ }
779
+ },
780
+ trim: function (str) {
781
+ if (String.prototype.trim) {
782
+ return str.trim();
783
+ }
784
+ return str.replace(/(^\s*)|(\s*$)/g, "");
785
+ },
786
+ spaceIndex: function (str) {
787
+ var reg = /\s|\n|\t/;
788
+ var match = reg.exec(str);
789
+ return match ? match.index : -1;
790
+ },
791
+ };
792
+
793
+ },{}],5:[function(require,module,exports){
794
+ /**
795
+ * filter xss
796
+ *
797
+ * @author Zongmin Lei<leizongmin@gmail.com>
798
+ */
799
+
800
+ var FilterCSS = require("cssfilter").FilterCSS;
801
+ var DEFAULT = require("./default");
802
+ var parser = require("./parser");
803
+ var parseTag = parser.parseTag;
804
+ var parseAttr = parser.parseAttr;
805
+ var _ = require("./util");
806
+
807
+ /**
808
+ * returns `true` if the input value is `undefined` or `null`
809
+ *
810
+ * @param {Object} obj
811
+ * @return {Boolean}
812
+ */
813
+ function isNull(obj) {
814
+ return obj === undefined || obj === null;
815
+ }
816
+
817
+ /**
818
+ * get attributes for a tag
819
+ *
820
+ * @param {String} html
821
+ * @return {Object}
822
+ * - {String} html
823
+ * - {Boolean} closing
824
+ */
825
+ function getAttrs(html) {
826
+ var i = _.spaceIndex(html);
827
+ if (i === -1) {
828
+ return {
829
+ html: "",
830
+ closing: html[html.length - 2] === "/",
831
+ };
832
+ }
833
+ html = _.trim(html.slice(i + 1, -1));
834
+ var isClosing = html[html.length - 1] === "/";
835
+ if (isClosing) html = _.trim(html.slice(0, -1));
836
+ return {
837
+ html: html,
838
+ closing: isClosing,
839
+ };
840
+ }
841
+
842
+ /**
843
+ * shallow copy
844
+ *
845
+ * @param {Object} obj
846
+ * @return {Object}
847
+ */
848
+ function shallowCopyObject(obj) {
849
+ var ret = {};
850
+ for (var i in obj) {
851
+ ret[i] = obj[i];
852
+ }
853
+ return ret;
854
+ }
855
+
856
+ /**
857
+ * FilterXSS class
858
+ *
859
+ * @param {Object} options
860
+ * whiteList, onTag, onTagAttr, onIgnoreTag,
861
+ * onIgnoreTagAttr, safeAttrValue, escapeHtml
862
+ * stripIgnoreTagBody, allowCommentTag, stripBlankChar
863
+ * css{whiteList, onAttr, onIgnoreAttr} `css=false` means don't use `cssfilter`
864
+ */
865
+ function FilterXSS(options) {
866
+ options = shallowCopyObject(options || {});
867
+
868
+ if (options.stripIgnoreTag) {
869
+ if (options.onIgnoreTag) {
870
+ console.error(
871
+ 'Notes: cannot use these two options "stripIgnoreTag" and "onIgnoreTag" at the same time'
872
+ );
873
+ }
874
+ options.onIgnoreTag = DEFAULT.onIgnoreTagStripAll;
875
+ }
876
+
877
+ options.whiteList = options.whiteList || DEFAULT.whiteList;
878
+ options.onTag = options.onTag || DEFAULT.onTag;
879
+ options.onTagAttr = options.onTagAttr || DEFAULT.onTagAttr;
880
+ options.onIgnoreTag = options.onIgnoreTag || DEFAULT.onIgnoreTag;
881
+ options.onIgnoreTagAttr = options.onIgnoreTagAttr || DEFAULT.onIgnoreTagAttr;
882
+ options.safeAttrValue = options.safeAttrValue || DEFAULT.safeAttrValue;
883
+ options.escapeHtml = options.escapeHtml || DEFAULT.escapeHtml;
884
+ this.options = options;
885
+
886
+ if (options.css === false) {
887
+ this.cssFilter = false;
888
+ } else {
889
+ options.css = options.css || {};
890
+ this.cssFilter = new FilterCSS(options.css);
891
+ }
892
+ }
893
+
894
+ /**
895
+ * start process and returns result
896
+ *
897
+ * @param {String} html
898
+ * @return {String}
899
+ */
900
+ FilterXSS.prototype.process = function (html) {
901
+ // compatible with the input
902
+ html = html || "";
903
+ html = html.toString();
904
+ if (!html) return "";
905
+
906
+ var me = this;
907
+ var options = me.options;
908
+ var whiteList = options.whiteList;
909
+ var onTag = options.onTag;
910
+ var onIgnoreTag = options.onIgnoreTag;
911
+ var onTagAttr = options.onTagAttr;
912
+ var onIgnoreTagAttr = options.onIgnoreTagAttr;
913
+ var safeAttrValue = options.safeAttrValue;
914
+ var escapeHtml = options.escapeHtml;
915
+ var cssFilter = me.cssFilter;
916
+
917
+ // remove invisible characters
918
+ if (options.stripBlankChar) {
919
+ html = DEFAULT.stripBlankChar(html);
920
+ }
921
+
922
+ // remove html comments
923
+ if (!options.allowCommentTag) {
924
+ html = DEFAULT.stripCommentTag(html);
925
+ }
926
+
927
+ // if enable stripIgnoreTagBody
928
+ var stripIgnoreTagBody = false;
929
+ if (options.stripIgnoreTagBody) {
930
+ var stripIgnoreTagBody = DEFAULT.StripTagBody(
931
+ options.stripIgnoreTagBody,
932
+ onIgnoreTag
933
+ );
934
+ onIgnoreTag = stripIgnoreTagBody.onIgnoreTag;
935
+ }
936
+
937
+ var retHtml = parseTag(
938
+ html,
939
+ function (sourcePosition, position, tag, html, isClosing) {
940
+ var info = {
941
+ sourcePosition: sourcePosition,
942
+ position: position,
943
+ isClosing: isClosing,
944
+ isWhite: whiteList.hasOwnProperty(tag),
945
+ };
946
+
947
+ // call `onTag()`
948
+ var ret = onTag(tag, html, info);
949
+ if (!isNull(ret)) return ret;
950
+
951
+ if (info.isWhite) {
952
+ if (info.isClosing) {
953
+ return "</" + tag + ">";
954
+ }
955
+
956
+ var attrs = getAttrs(html);
957
+ var whiteAttrList = whiteList[tag];
958
+ var attrsHtml = parseAttr(attrs.html, function (name, value) {
959
+ // call `onTagAttr()`
960
+ var isWhiteAttr = _.indexOf(whiteAttrList, name) !== -1;
961
+ var ret = onTagAttr(tag, name, value, isWhiteAttr);
962
+ if (!isNull(ret)) return ret;
963
+
964
+ if (isWhiteAttr) {
965
+ // call `safeAttrValue()`
966
+ value = safeAttrValue(tag, name, value, cssFilter);
967
+ if (value) {
968
+ return name + '="' + value + '"';
969
+ } else {
970
+ return name;
971
+ }
972
+ } else {
973
+ // call `onIgnoreTagAttr()`
974
+ var ret = onIgnoreTagAttr(tag, name, value, isWhiteAttr);
975
+ if (!isNull(ret)) return ret;
976
+ return;
977
+ }
978
+ });
979
+
980
+ // build new tag html
981
+ var html = "<" + tag;
982
+ if (attrsHtml) html += " " + attrsHtml;
983
+ if (attrs.closing) html += " /";
984
+ html += ">";
985
+ return html;
986
+ } else {
987
+ // call `onIgnoreTag()`
988
+ var ret = onIgnoreTag(tag, html, info);
989
+ if (!isNull(ret)) return ret;
990
+ return escapeHtml(html);
991
+ }
992
+ },
993
+ escapeHtml
994
+ );
995
+
996
+ // if enable stripIgnoreTagBody
997
+ if (stripIgnoreTagBody) {
998
+ retHtml = stripIgnoreTagBody.remove(retHtml);
999
+ }
1000
+
1001
+ return retHtml;
1002
+ };
1003
+
1004
+ module.exports = FilterXSS;
1005
+
1006
+ },{"./default":1,"./parser":3,"./util":4,"cssfilter":8}],6:[function(require,module,exports){
1007
+ /**
1008
+ * cssfilter
1009
+ *
1010
+ * @author 老雷<leizongmin@gmail.com>
1011
+ */
1012
+
1013
+ var DEFAULT = require('./default');
1014
+ var parseStyle = require('./parser');
1015
+ var _ = require('./util');
1016
+
1017
+
1018
+ /**
1019
+ * 返回值是否为空
1020
+ *
1021
+ * @param {Object} obj
1022
+ * @return {Boolean}
1023
+ */
1024
+ function isNull (obj) {
1025
+ return (obj === undefined || obj === null);
1026
+ }
1027
+
1028
+ /**
1029
+ * 浅拷贝对象
1030
+ *
1031
+ * @param {Object} obj
1032
+ * @return {Object}
1033
+ */
1034
+ function shallowCopyObject (obj) {
1035
+ var ret = {};
1036
+ for (var i in obj) {
1037
+ ret[i] = obj[i];
1038
+ }
1039
+ return ret;
1040
+ }
1041
+
1042
+ /**
1043
+ * 创建CSS过滤器
1044
+ *
1045
+ * @param {Object} options
1046
+ * - {Object} whiteList
1047
+ * - {Function} onAttr
1048
+ * - {Function} onIgnoreAttr
1049
+ * - {Function} safeAttrValue
1050
+ */
1051
+ function FilterCSS (options) {
1052
+ options = shallowCopyObject(options || {});
1053
+ options.whiteList = options.whiteList || DEFAULT.whiteList;
1054
+ options.onAttr = options.onAttr || DEFAULT.onAttr;
1055
+ options.onIgnoreAttr = options.onIgnoreAttr || DEFAULT.onIgnoreAttr;
1056
+ options.safeAttrValue = options.safeAttrValue || DEFAULT.safeAttrValue;
1057
+ this.options = options;
1058
+ }
1059
+
1060
+ FilterCSS.prototype.process = function (css) {
1061
+ // 兼容各种奇葩输入
1062
+ css = css || '';
1063
+ css = css.toString();
1064
+ if (!css) return '';
1065
+
1066
+ var me = this;
1067
+ var options = me.options;
1068
+ var whiteList = options.whiteList;
1069
+ var onAttr = options.onAttr;
1070
+ var onIgnoreAttr = options.onIgnoreAttr;
1071
+ var safeAttrValue = options.safeAttrValue;
1072
+
1073
+ var retCSS = parseStyle(css, function (sourcePosition, position, name, value, source) {
1074
+
1075
+ var check = whiteList[name];
1076
+ var isWhite = false;
1077
+ if (check === true) isWhite = check;
1078
+ else if (typeof check === 'function') isWhite = check(value);
1079
+ else if (check instanceof RegExp) isWhite = check.test(value);
1080
+ if (isWhite !== true) isWhite = false;
1081
+
1082
+ // 如果过滤后 value 为空则直接忽略
1083
+ value = safeAttrValue(name, value);
1084
+ if (!value) return;
1085
+
1086
+ var opts = {
1087
+ position: position,
1088
+ sourcePosition: sourcePosition,
1089
+ source: source,
1090
+ isWhite: isWhite
1091
+ };
1092
+
1093
+ if (isWhite) {
1094
+
1095
+ var ret = onAttr(name, value, opts);
1096
+ if (isNull(ret)) {
1097
+ return name + ':' + value;
1098
+ } else {
1099
+ return ret;
1100
+ }
1101
+
1102
+ } else {
1103
+
1104
+ var ret = onIgnoreAttr(name, value, opts);
1105
+ if (!isNull(ret)) {
1106
+ return ret;
1107
+ }
1108
+
1109
+ }
1110
+ });
1111
+
1112
+ return retCSS;
1113
+ };
1114
+
1115
+
1116
+ module.exports = FilterCSS;
1117
+
1118
+ },{"./default":7,"./parser":9,"./util":10}],7:[function(require,module,exports){
1119
+ /**
1120
+ * cssfilter
1121
+ *
1122
+ * @author 老雷<leizongmin@gmail.com>
1123
+ */
1124
+
1125
+ function getDefaultWhiteList () {
1126
+ // 白名单值说明:
1127
+ // true: 允许该属性
1128
+ // Function: function (val) { } 返回true表示允许该属性,其他值均表示不允许
1129
+ // RegExp: regexp.test(val) 返回true表示允许该属性,其他值均表示不允许
1130
+ // 除上面列出的值外均表示不允许
1131
+ var whiteList = {};
1132
+
1133
+ whiteList['align-content'] = false; // default: auto
1134
+ whiteList['align-items'] = false; // default: auto
1135
+ whiteList['align-self'] = false; // default: auto
1136
+ whiteList['alignment-adjust'] = false; // default: auto
1137
+ whiteList['alignment-baseline'] = false; // default: baseline
1138
+ whiteList['all'] = false; // default: depending on individual properties
1139
+ whiteList['anchor-point'] = false; // default: none
1140
+ whiteList['animation'] = false; // default: depending on individual properties
1141
+ whiteList['animation-delay'] = false; // default: 0
1142
+ whiteList['animation-direction'] = false; // default: normal
1143
+ whiteList['animation-duration'] = false; // default: 0
1144
+ whiteList['animation-fill-mode'] = false; // default: none
1145
+ whiteList['animation-iteration-count'] = false; // default: 1
1146
+ whiteList['animation-name'] = false; // default: none
1147
+ whiteList['animation-play-state'] = false; // default: running
1148
+ whiteList['animation-timing-function'] = false; // default: ease
1149
+ whiteList['azimuth'] = false; // default: center
1150
+ whiteList['backface-visibility'] = false; // default: visible
1151
+ whiteList['background'] = true; // default: depending on individual properties
1152
+ whiteList['background-attachment'] = true; // default: scroll
1153
+ whiteList['background-clip'] = true; // default: border-box
1154
+ whiteList['background-color'] = true; // default: transparent
1155
+ whiteList['background-image'] = true; // default: none
1156
+ whiteList['background-origin'] = true; // default: padding-box
1157
+ whiteList['background-position'] = true; // default: 0% 0%
1158
+ whiteList['background-repeat'] = true; // default: repeat
1159
+ whiteList['background-size'] = true; // default: auto
1160
+ whiteList['baseline-shift'] = false; // default: baseline
1161
+ whiteList['binding'] = false; // default: none
1162
+ whiteList['bleed'] = false; // default: 6pt
1163
+ whiteList['bookmark-label'] = false; // default: content()
1164
+ whiteList['bookmark-level'] = false; // default: none
1165
+ whiteList['bookmark-state'] = false; // default: open
1166
+ whiteList['border'] = true; // default: depending on individual properties
1167
+ whiteList['border-bottom'] = true; // default: depending on individual properties
1168
+ whiteList['border-bottom-color'] = true; // default: current color
1169
+ whiteList['border-bottom-left-radius'] = true; // default: 0
1170
+ whiteList['border-bottom-right-radius'] = true; // default: 0
1171
+ whiteList['border-bottom-style'] = true; // default: none
1172
+ whiteList['border-bottom-width'] = true; // default: medium
1173
+ whiteList['border-collapse'] = true; // default: separate
1174
+ whiteList['border-color'] = true; // default: depending on individual properties
1175
+ whiteList['border-image'] = true; // default: none
1176
+ whiteList['border-image-outset'] = true; // default: 0
1177
+ whiteList['border-image-repeat'] = true; // default: stretch
1178
+ whiteList['border-image-slice'] = true; // default: 100%
1179
+ whiteList['border-image-source'] = true; // default: none
1180
+ whiteList['border-image-width'] = true; // default: 1
1181
+ whiteList['border-left'] = true; // default: depending on individual properties
1182
+ whiteList['border-left-color'] = true; // default: current color
1183
+ whiteList['border-left-style'] = true; // default: none
1184
+ whiteList['border-left-width'] = true; // default: medium
1185
+ whiteList['border-radius'] = true; // default: 0
1186
+ whiteList['border-right'] = true; // default: depending on individual properties
1187
+ whiteList['border-right-color'] = true; // default: current color
1188
+ whiteList['border-right-style'] = true; // default: none
1189
+ whiteList['border-right-width'] = true; // default: medium
1190
+ whiteList['border-spacing'] = true; // default: 0
1191
+ whiteList['border-style'] = true; // default: depending on individual properties
1192
+ whiteList['border-top'] = true; // default: depending on individual properties
1193
+ whiteList['border-top-color'] = true; // default: current color
1194
+ whiteList['border-top-left-radius'] = true; // default: 0
1195
+ whiteList['border-top-right-radius'] = true; // default: 0
1196
+ whiteList['border-top-style'] = true; // default: none
1197
+ whiteList['border-top-width'] = true; // default: medium
1198
+ whiteList['border-width'] = true; // default: depending on individual properties
1199
+ whiteList['bottom'] = false; // default: auto
1200
+ whiteList['box-decoration-break'] = true; // default: slice
1201
+ whiteList['box-shadow'] = true; // default: none
1202
+ whiteList['box-sizing'] = true; // default: content-box
1203
+ whiteList['box-snap'] = true; // default: none
1204
+ whiteList['box-suppress'] = true; // default: show
1205
+ whiteList['break-after'] = true; // default: auto
1206
+ whiteList['break-before'] = true; // default: auto
1207
+ whiteList['break-inside'] = true; // default: auto
1208
+ whiteList['caption-side'] = false; // default: top
1209
+ whiteList['chains'] = false; // default: none
1210
+ whiteList['clear'] = true; // default: none
1211
+ whiteList['clip'] = false; // default: auto
1212
+ whiteList['clip-path'] = false; // default: none
1213
+ whiteList['clip-rule'] = false; // default: nonzero
1214
+ whiteList['color'] = true; // default: implementation dependent
1215
+ whiteList['color-interpolation-filters'] = true; // default: auto
1216
+ whiteList['column-count'] = false; // default: auto
1217
+ whiteList['column-fill'] = false; // default: balance
1218
+ whiteList['column-gap'] = false; // default: normal
1219
+ whiteList['column-rule'] = false; // default: depending on individual properties
1220
+ whiteList['column-rule-color'] = false; // default: current color
1221
+ whiteList['column-rule-style'] = false; // default: medium
1222
+ whiteList['column-rule-width'] = false; // default: medium
1223
+ whiteList['column-span'] = false; // default: none
1224
+ whiteList['column-width'] = false; // default: auto
1225
+ whiteList['columns'] = false; // default: depending on individual properties
1226
+ whiteList['contain'] = false; // default: none
1227
+ whiteList['content'] = false; // default: normal
1228
+ whiteList['counter-increment'] = false; // default: none
1229
+ whiteList['counter-reset'] = false; // default: none
1230
+ whiteList['counter-set'] = false; // default: none
1231
+ whiteList['crop'] = false; // default: auto
1232
+ whiteList['cue'] = false; // default: depending on individual properties
1233
+ whiteList['cue-after'] = false; // default: none
1234
+ whiteList['cue-before'] = false; // default: none
1235
+ whiteList['cursor'] = false; // default: auto
1236
+ whiteList['direction'] = false; // default: ltr
1237
+ whiteList['display'] = true; // default: depending on individual properties
1238
+ whiteList['display-inside'] = true; // default: auto
1239
+ whiteList['display-list'] = true; // default: none
1240
+ whiteList['display-outside'] = true; // default: inline-level
1241
+ whiteList['dominant-baseline'] = false; // default: auto
1242
+ whiteList['elevation'] = false; // default: level
1243
+ whiteList['empty-cells'] = false; // default: show
1244
+ whiteList['filter'] = false; // default: none
1245
+ whiteList['flex'] = false; // default: depending on individual properties
1246
+ whiteList['flex-basis'] = false; // default: auto
1247
+ whiteList['flex-direction'] = false; // default: row
1248
+ whiteList['flex-flow'] = false; // default: depending on individual properties
1249
+ whiteList['flex-grow'] = false; // default: 0
1250
+ whiteList['flex-shrink'] = false; // default: 1
1251
+ whiteList['flex-wrap'] = false; // default: nowrap
1252
+ whiteList['float'] = false; // default: none
1253
+ whiteList['float-offset'] = false; // default: 0 0
1254
+ whiteList['flood-color'] = false; // default: black
1255
+ whiteList['flood-opacity'] = false; // default: 1
1256
+ whiteList['flow-from'] = false; // default: none
1257
+ whiteList['flow-into'] = false; // default: none
1258
+ whiteList['font'] = true; // default: depending on individual properties
1259
+ whiteList['font-family'] = true; // default: implementation dependent
1260
+ whiteList['font-feature-settings'] = true; // default: normal
1261
+ whiteList['font-kerning'] = true; // default: auto
1262
+ whiteList['font-language-override'] = true; // default: normal
1263
+ whiteList['font-size'] = true; // default: medium
1264
+ whiteList['font-size-adjust'] = true; // default: none
1265
+ whiteList['font-stretch'] = true; // default: normal
1266
+ whiteList['font-style'] = true; // default: normal
1267
+ whiteList['font-synthesis'] = true; // default: weight style
1268
+ whiteList['font-variant'] = true; // default: normal
1269
+ whiteList['font-variant-alternates'] = true; // default: normal
1270
+ whiteList['font-variant-caps'] = true; // default: normal
1271
+ whiteList['font-variant-east-asian'] = true; // default: normal
1272
+ whiteList['font-variant-ligatures'] = true; // default: normal
1273
+ whiteList['font-variant-numeric'] = true; // default: normal
1274
+ whiteList['font-variant-position'] = true; // default: normal
1275
+ whiteList['font-weight'] = true; // default: normal
1276
+ whiteList['grid'] = false; // default: depending on individual properties
1277
+ whiteList['grid-area'] = false; // default: depending on individual properties
1278
+ whiteList['grid-auto-columns'] = false; // default: auto
1279
+ whiteList['grid-auto-flow'] = false; // default: none
1280
+ whiteList['grid-auto-rows'] = false; // default: auto
1281
+ whiteList['grid-column'] = false; // default: depending on individual properties
1282
+ whiteList['grid-column-end'] = false; // default: auto
1283
+ whiteList['grid-column-start'] = false; // default: auto
1284
+ whiteList['grid-row'] = false; // default: depending on individual properties
1285
+ whiteList['grid-row-end'] = false; // default: auto
1286
+ whiteList['grid-row-start'] = false; // default: auto
1287
+ whiteList['grid-template'] = false; // default: depending on individual properties
1288
+ whiteList['grid-template-areas'] = false; // default: none
1289
+ whiteList['grid-template-columns'] = false; // default: none
1290
+ whiteList['grid-template-rows'] = false; // default: none
1291
+ whiteList['hanging-punctuation'] = false; // default: none
1292
+ whiteList['height'] = true; // default: auto
1293
+ whiteList['hyphens'] = false; // default: manual
1294
+ whiteList['icon'] = false; // default: auto
1295
+ whiteList['image-orientation'] = false; // default: auto
1296
+ whiteList['image-resolution'] = false; // default: normal
1297
+ whiteList['ime-mode'] = false; // default: auto
1298
+ whiteList['initial-letters'] = false; // default: normal
1299
+ whiteList['inline-box-align'] = false; // default: last
1300
+ whiteList['justify-content'] = false; // default: auto
1301
+ whiteList['justify-items'] = false; // default: auto
1302
+ whiteList['justify-self'] = false; // default: auto
1303
+ whiteList['left'] = false; // default: auto
1304
+ whiteList['letter-spacing'] = true; // default: normal
1305
+ whiteList['lighting-color'] = true; // default: white
1306
+ whiteList['line-box-contain'] = false; // default: block inline replaced
1307
+ whiteList['line-break'] = false; // default: auto
1308
+ whiteList['line-grid'] = false; // default: match-parent
1309
+ whiteList['line-height'] = false; // default: normal
1310
+ whiteList['line-snap'] = false; // default: none
1311
+ whiteList['line-stacking'] = false; // default: depending on individual properties
1312
+ whiteList['line-stacking-ruby'] = false; // default: exclude-ruby
1313
+ whiteList['line-stacking-shift'] = false; // default: consider-shifts
1314
+ whiteList['line-stacking-strategy'] = false; // default: inline-line-height
1315
+ whiteList['list-style'] = true; // default: depending on individual properties
1316
+ whiteList['list-style-image'] = true; // default: none
1317
+ whiteList['list-style-position'] = true; // default: outside
1318
+ whiteList['list-style-type'] = true; // default: disc
1319
+ whiteList['margin'] = true; // default: depending on individual properties
1320
+ whiteList['margin-bottom'] = true; // default: 0
1321
+ whiteList['margin-left'] = true; // default: 0
1322
+ whiteList['margin-right'] = true; // default: 0
1323
+ whiteList['margin-top'] = true; // default: 0
1324
+ whiteList['marker-offset'] = false; // default: auto
1325
+ whiteList['marker-side'] = false; // default: list-item
1326
+ whiteList['marks'] = false; // default: none
1327
+ whiteList['mask'] = false; // default: border-box
1328
+ whiteList['mask-box'] = false; // default: see individual properties
1329
+ whiteList['mask-box-outset'] = false; // default: 0
1330
+ whiteList['mask-box-repeat'] = false; // default: stretch
1331
+ whiteList['mask-box-slice'] = false; // default: 0 fill
1332
+ whiteList['mask-box-source'] = false; // default: none
1333
+ whiteList['mask-box-width'] = false; // default: auto
1334
+ whiteList['mask-clip'] = false; // default: border-box
1335
+ whiteList['mask-image'] = false; // default: none
1336
+ whiteList['mask-origin'] = false; // default: border-box
1337
+ whiteList['mask-position'] = false; // default: center
1338
+ whiteList['mask-repeat'] = false; // default: no-repeat
1339
+ whiteList['mask-size'] = false; // default: border-box
1340
+ whiteList['mask-source-type'] = false; // default: auto
1341
+ whiteList['mask-type'] = false; // default: luminance
1342
+ whiteList['max-height'] = true; // default: none
1343
+ whiteList['max-lines'] = false; // default: none
1344
+ whiteList['max-width'] = true; // default: none
1345
+ whiteList['min-height'] = true; // default: 0
1346
+ whiteList['min-width'] = true; // default: 0
1347
+ whiteList['move-to'] = false; // default: normal
1348
+ whiteList['nav-down'] = false; // default: auto
1349
+ whiteList['nav-index'] = false; // default: auto
1350
+ whiteList['nav-left'] = false; // default: auto
1351
+ whiteList['nav-right'] = false; // default: auto
1352
+ whiteList['nav-up'] = false; // default: auto
1353
+ whiteList['object-fit'] = false; // default: fill
1354
+ whiteList['object-position'] = false; // default: 50% 50%
1355
+ whiteList['opacity'] = false; // default: 1
1356
+ whiteList['order'] = false; // default: 0
1357
+ whiteList['orphans'] = false; // default: 2
1358
+ whiteList['outline'] = false; // default: depending on individual properties
1359
+ whiteList['outline-color'] = false; // default: invert
1360
+ whiteList['outline-offset'] = false; // default: 0
1361
+ whiteList['outline-style'] = false; // default: none
1362
+ whiteList['outline-width'] = false; // default: medium
1363
+ whiteList['overflow'] = false; // default: depending on individual properties
1364
+ whiteList['overflow-wrap'] = false; // default: normal
1365
+ whiteList['overflow-x'] = false; // default: visible
1366
+ whiteList['overflow-y'] = false; // default: visible
1367
+ whiteList['padding'] = true; // default: depending on individual properties
1368
+ whiteList['padding-bottom'] = true; // default: 0
1369
+ whiteList['padding-left'] = true; // default: 0
1370
+ whiteList['padding-right'] = true; // default: 0
1371
+ whiteList['padding-top'] = true; // default: 0
1372
+ whiteList['page'] = false; // default: auto
1373
+ whiteList['page-break-after'] = false; // default: auto
1374
+ whiteList['page-break-before'] = false; // default: auto
1375
+ whiteList['page-break-inside'] = false; // default: auto
1376
+ whiteList['page-policy'] = false; // default: start
1377
+ whiteList['pause'] = false; // default: implementation dependent
1378
+ whiteList['pause-after'] = false; // default: implementation dependent
1379
+ whiteList['pause-before'] = false; // default: implementation dependent
1380
+ whiteList['perspective'] = false; // default: none
1381
+ whiteList['perspective-origin'] = false; // default: 50% 50%
1382
+ whiteList['pitch'] = false; // default: medium
1383
+ whiteList['pitch-range'] = false; // default: 50
1384
+ whiteList['play-during'] = false; // default: auto
1385
+ whiteList['position'] = false; // default: static
1386
+ whiteList['presentation-level'] = false; // default: 0
1387
+ whiteList['quotes'] = false; // default: text
1388
+ whiteList['region-fragment'] = false; // default: auto
1389
+ whiteList['resize'] = false; // default: none
1390
+ whiteList['rest'] = false; // default: depending on individual properties
1391
+ whiteList['rest-after'] = false; // default: none
1392
+ whiteList['rest-before'] = false; // default: none
1393
+ whiteList['richness'] = false; // default: 50
1394
+ whiteList['right'] = false; // default: auto
1395
+ whiteList['rotation'] = false; // default: 0
1396
+ whiteList['rotation-point'] = false; // default: 50% 50%
1397
+ whiteList['ruby-align'] = false; // default: auto
1398
+ whiteList['ruby-merge'] = false; // default: separate
1399
+ whiteList['ruby-position'] = false; // default: before
1400
+ whiteList['shape-image-threshold'] = false; // default: 0.0
1401
+ whiteList['shape-outside'] = false; // default: none
1402
+ whiteList['shape-margin'] = false; // default: 0
1403
+ whiteList['size'] = false; // default: auto
1404
+ whiteList['speak'] = false; // default: auto
1405
+ whiteList['speak-as'] = false; // default: normal
1406
+ whiteList['speak-header'] = false; // default: once
1407
+ whiteList['speak-numeral'] = false; // default: continuous
1408
+ whiteList['speak-punctuation'] = false; // default: none
1409
+ whiteList['speech-rate'] = false; // default: medium
1410
+ whiteList['stress'] = false; // default: 50
1411
+ whiteList['string-set'] = false; // default: none
1412
+ whiteList['tab-size'] = false; // default: 8
1413
+ whiteList['table-layout'] = false; // default: auto
1414
+ whiteList['text-align'] = true; // default: start
1415
+ whiteList['text-align-last'] = true; // default: auto
1416
+ whiteList['text-combine-upright'] = true; // default: none
1417
+ whiteList['text-decoration'] = true; // default: none
1418
+ whiteList['text-decoration-color'] = true; // default: currentColor
1419
+ whiteList['text-decoration-line'] = true; // default: none
1420
+ whiteList['text-decoration-skip'] = true; // default: objects
1421
+ whiteList['text-decoration-style'] = true; // default: solid
1422
+ whiteList['text-emphasis'] = true; // default: depending on individual properties
1423
+ whiteList['text-emphasis-color'] = true; // default: currentColor
1424
+ whiteList['text-emphasis-position'] = true; // default: over right
1425
+ whiteList['text-emphasis-style'] = true; // default: none
1426
+ whiteList['text-height'] = true; // default: auto
1427
+ whiteList['text-indent'] = true; // default: 0
1428
+ whiteList['text-justify'] = true; // default: auto
1429
+ whiteList['text-orientation'] = true; // default: mixed
1430
+ whiteList['text-overflow'] = true; // default: clip
1431
+ whiteList['text-shadow'] = true; // default: none
1432
+ whiteList['text-space-collapse'] = true; // default: collapse
1433
+ whiteList['text-transform'] = true; // default: none
1434
+ whiteList['text-underline-position'] = true; // default: auto
1435
+ whiteList['text-wrap'] = true; // default: normal
1436
+ whiteList['top'] = false; // default: auto
1437
+ whiteList['transform'] = false; // default: none
1438
+ whiteList['transform-origin'] = false; // default: 50% 50% 0
1439
+ whiteList['transform-style'] = false; // default: flat
1440
+ whiteList['transition'] = false; // default: depending on individual properties
1441
+ whiteList['transition-delay'] = false; // default: 0s
1442
+ whiteList['transition-duration'] = false; // default: 0s
1443
+ whiteList['transition-property'] = false; // default: all
1444
+ whiteList['transition-timing-function'] = false; // default: ease
1445
+ whiteList['unicode-bidi'] = false; // default: normal
1446
+ whiteList['vertical-align'] = false; // default: baseline
1447
+ whiteList['visibility'] = false; // default: visible
1448
+ whiteList['voice-balance'] = false; // default: center
1449
+ whiteList['voice-duration'] = false; // default: auto
1450
+ whiteList['voice-family'] = false; // default: implementation dependent
1451
+ whiteList['voice-pitch'] = false; // default: medium
1452
+ whiteList['voice-range'] = false; // default: medium
1453
+ whiteList['voice-rate'] = false; // default: normal
1454
+ whiteList['voice-stress'] = false; // default: normal
1455
+ whiteList['voice-volume'] = false; // default: medium
1456
+ whiteList['volume'] = false; // default: medium
1457
+ whiteList['white-space'] = false; // default: normal
1458
+ whiteList['widows'] = false; // default: 2
1459
+ whiteList['width'] = true; // default: auto
1460
+ whiteList['will-change'] = false; // default: auto
1461
+ whiteList['word-break'] = true; // default: normal
1462
+ whiteList['word-spacing'] = true; // default: normal
1463
+ whiteList['word-wrap'] = true; // default: normal
1464
+ whiteList['wrap-flow'] = false; // default: auto
1465
+ whiteList['wrap-through'] = false; // default: wrap
1466
+ whiteList['writing-mode'] = false; // default: horizontal-tb
1467
+ whiteList['z-index'] = false; // default: auto
1468
+
1469
+ return whiteList;
1470
+ }
1471
+
1472
+
1473
+ /**
1474
+ * 匹配到白名单上的一个属性时
1475
+ *
1476
+ * @param {String} name
1477
+ * @param {String} value
1478
+ * @param {Object} options
1479
+ * @return {String}
1480
+ */
1481
+ function onAttr (name, value, options) {
1482
+ // do nothing
1483
+ }
1484
+
1485
+ /**
1486
+ * 匹配到不在白名单上的一个属性时
1487
+ *
1488
+ * @param {String} name
1489
+ * @param {String} value
1490
+ * @param {Object} options
1491
+ * @return {String}
1492
+ */
1493
+ function onIgnoreAttr (name, value, options) {
1494
+ // do nothing
1495
+ }
1496
+
1497
+ var REGEXP_URL_JAVASCRIPT = /javascript\s*\:/img;
1498
+
1499
+ /**
1500
+ * 过滤属性值
1501
+ *
1502
+ * @param {String} name
1503
+ * @param {String} value
1504
+ * @return {String}
1505
+ */
1506
+ function safeAttrValue(name, value) {
1507
+ if (REGEXP_URL_JAVASCRIPT.test(value)) return '';
1508
+ return value;
1509
+ }
1510
+
1511
+
1512
+ exports.whiteList = getDefaultWhiteList();
1513
+ exports.getDefaultWhiteList = getDefaultWhiteList;
1514
+ exports.onAttr = onAttr;
1515
+ exports.onIgnoreAttr = onIgnoreAttr;
1516
+ exports.safeAttrValue = safeAttrValue;
1517
+
1518
+ },{}],8:[function(require,module,exports){
1519
+ /**
1520
+ * cssfilter
1521
+ *
1522
+ * @author 老雷<leizongmin@gmail.com>
1523
+ */
1524
+
1525
+ var DEFAULT = require('./default');
1526
+ var FilterCSS = require('./css');
1527
+
1528
+
1529
+ /**
1530
+ * XSS过滤
1531
+ *
1532
+ * @param {String} css 要过滤的CSS代码
1533
+ * @param {Object} options 选项:whiteList, onAttr, onIgnoreAttr
1534
+ * @return {String}
1535
+ */
1536
+ function filterCSS (html, options) {
1537
+ var xss = new FilterCSS(options);
1538
+ return xss.process(html);
1539
+ }
1540
+
1541
+
1542
+ // 输出
1543
+ exports = module.exports = filterCSS;
1544
+ exports.FilterCSS = FilterCSS;
1545
+ for (var i in DEFAULT) exports[i] = DEFAULT[i];
1546
+
1547
+ // 在浏览器端使用
1548
+ if (typeof window !== 'undefined') {
1549
+ window.filterCSS = module.exports;
1550
+ }
1551
+
1552
+ },{"./css":6,"./default":7}],9:[function(require,module,exports){
1553
+ /**
1554
+ * cssfilter
1555
+ *
1556
+ * @author 老雷<leizongmin@gmail.com>
1557
+ */
1558
+
1559
+ var _ = require('./util');
1560
+
1561
+
1562
+ /**
1563
+ * 解析style
1564
+ *
1565
+ * @param {String} css
1566
+ * @param {Function} onAttr 处理属性的函数
1567
+ * 参数格式: function (sourcePosition, position, name, value, source)
1568
+ * @return {String}
1569
+ */
1570
+ function parseStyle (css, onAttr) {
1571
+ css = _.trimRight(css);
1572
+ if (css[css.length - 1] !== ';') css += ';';
1573
+ var cssLength = css.length;
1574
+ var isParenthesisOpen = false;
1575
+ var lastPos = 0;
1576
+ var i = 0;
1577
+ var retCSS = '';
1578
+
1579
+ function addNewAttr () {
1580
+ // 如果没有正常的闭合圆括号,则直接忽略当前属性
1581
+ if (!isParenthesisOpen) {
1582
+ var source = _.trim(css.slice(lastPos, i));
1583
+ var j = source.indexOf(':');
1584
+ if (j !== -1) {
1585
+ var name = _.trim(source.slice(0, j));
1586
+ var value = _.trim(source.slice(j + 1));
1587
+ // 必须有属性名称
1588
+ if (name) {
1589
+ var ret = onAttr(lastPos, retCSS.length, name, value, source);
1590
+ if (ret) retCSS += ret + '; ';
1591
+ }
1592
+ }
1593
+ }
1594
+ lastPos = i + 1;
1595
+ }
1596
+
1597
+ for (; i < cssLength; i++) {
1598
+ var c = css[i];
1599
+ if (c === '/' && css[i + 1] === '*') {
1600
+ // 备注开始
1601
+ var j = css.indexOf('*/', i + 2);
1602
+ // 如果没有正常的备注结束,则后面的部分全部跳过
1603
+ if (j === -1) break;
1604
+ // 直接将当前位置调到备注结尾,并且初始化状态
1605
+ i = j + 1;
1606
+ lastPos = i + 1;
1607
+ isParenthesisOpen = false;
1608
+ } else if (c === '(') {
1609
+ isParenthesisOpen = true;
1610
+ } else if (c === ')') {
1611
+ isParenthesisOpen = false;
1612
+ } else if (c === ';') {
1613
+ if (isParenthesisOpen) {
1614
+ // 在圆括号里面,忽略
1615
+ } else {
1616
+ addNewAttr();
1617
+ }
1618
+ } else if (c === '\n') {
1619
+ addNewAttr();
1620
+ }
1621
+ }
1622
+
1623
+ return _.trim(retCSS);
1624
+ }
1625
+
1626
+ module.exports = parseStyle;
1627
+
1628
+ },{"./util":10}],10:[function(require,module,exports){
1629
+ module.exports = {
1630
+ indexOf: function (arr, item) {
1631
+ var i, j;
1632
+ if (Array.prototype.indexOf) {
1633
+ return arr.indexOf(item);
1634
+ }
1635
+ for (i = 0, j = arr.length; i < j; i++) {
1636
+ if (arr[i] === item) {
1637
+ return i;
1638
+ }
1639
+ }
1640
+ return -1;
1641
+ },
1642
+ forEach: function (arr, fn, scope) {
1643
+ var i, j;
1644
+ if (Array.prototype.forEach) {
1645
+ return arr.forEach(fn, scope);
1646
+ }
1647
+ for (i = 0, j = arr.length; i < j; i++) {
1648
+ fn.call(scope, arr[i], i, arr);
1649
+ }
1650
+ },
1651
+ trim: function (str) {
1652
+ if (String.prototype.trim) {
1653
+ return str.trim();
1654
+ }
1655
+ return str.replace(/(^\s*)|(\s*$)/g, '');
1656
+ },
1657
+ trimRight: function (str) {
1658
+ if (String.prototype.trimRight) {
1659
+ return str.trimRight();
1660
+ }
1661
+ return str.replace(/(\s*$)/g, '');
1662
+ }
1663
+ };
1664
+
1665
+ },{}]},{},[2]);