You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 15, 2019. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,36 @@ var input = '...';
32
32
var result =purifier.purify(input);
33
33
```
34
34
35
+
## Advanced Usage
36
+
37
+
The following outlines the configuration that is secure by default. You should perform due dilligence to confirm your use cases are safe before disabling or altering the configurations.
38
+
39
+
```js
40
+
// The default configuration
41
+
newPurifier({
42
+
whitelistTags: ['a', '...'],
43
+
whitelistAttributes: ['href', '...'],
44
+
enableCanonicalization:true,
45
+
tagBalance: {
46
+
enabled:true,
47
+
stackSize:100
48
+
}
49
+
});
50
+
```
51
+
52
+
<!--
53
+
#### whitelistTags
54
+
55
+
#### whitelistAttributes
56
+
57
+
#### enableCanonicalization
58
+
-->
59
+
60
+
#### tagBalance
61
+
The untrusted data must be self-contained. Hence, it cannot close any tags prior to its inclusion, nor leave any of its own tags unclosed. An efficient and simple tag balancing algorithm is applied by default to enforce this goal only, and may not produce perfectly nested output. You may implement another tag balancing algorithm before invoking purify. But the default one should still be enabled, unless you're sure the self-contained requirement is met.
62
+
63
+
The ``stackSize`` (default: 100) is a limit imposed on the maximum number of unclosed tags (or the max levels of nested tags). When an untrusted data attempts to open tags that are so nested and has exceeded the allowed limit, the algorithm will cease any further processing but simply close all of those tags.
0 commit comments