Skip to content

Commit b161837

Browse files
committed
Add notes on security
1 parent 76e5601 commit b161837

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

readme.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ return, `\r`; or a carriage return + line feed, `\r\n`).
6565
If no `value` is given (empty string `''`, `null`, or `undefined`), the
6666
literal’s value is set to an empty string or the parent’s children are removed.
6767

68+
## Security
69+
70+
Improper use can open you up to a [cross-site scripting (XSS)][xss] attack as
71+
`value` is injected into the syntax tree.
72+
If operating on a `<script>` element, `value` will run in a browser.
73+
74+
Do not use user input in `value` when operating on `script` elements or use
75+
[`hast-util-santize`][sanitize].
76+
6877
## Related
6978

7079
* [`hast-util-to-text`](https://github.com/syntax-tree/hast-util-to-text)
@@ -143,3 +152,7 @@ abide by its terms.
143152
[text]: https://github.com/syntax-tree/hast#text
144153

145154
[element]: https://github.com/syntax-tree/hast#element
155+
156+
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
157+
158+
[sanitize]: https://github.com/syntax-tree/hast-util-sanitize

0 commit comments

Comments
 (0)