Skip to content

Commit

Permalink
hmtl: add security section to package comment
Browse files Browse the repository at this point in the history
Adds a short security considerations paragraph to the package comment
detailing the differences between the parser and tokenizer.

Change-Id: I9e6840b20f82ffc6bc4088fffd6b4eda97550c0a
Reviewed-on: https://go-review.googlesource.com/c/net/+/459676
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
  • Loading branch information
rolandshoemaker committed Mar 3, 2023
1 parent 1d46ed8 commit 8c4ef2f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions html/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ example, to process each anchor node in depth-first order:
The relevant specifications include:
https://html.spec.whatwg.org/multipage/syntax.html and
https://html.spec.whatwg.org/multipage/syntax.html#tokenization
# Security Considerations
Care should be taken when parsing and interpreting HTML, whether full documents
or fragments, within the framework of the HTML specification, especially with
regard to untrusted inputs.
This package provides both a tokenizer and a parser. Only the parser constructs
a DOM according to the HTML specification, resolving malformed and misplaced
tags where appropriate. The tokenizer simply tokenizes the HTML presented to it,
and as such does not resolve issues that may exist in the processed HTML,
producing a literal interpretation of the input.
If your use case requires semantically well-formed HTML, as defined by the
WHATWG specifiction, the parser should be used rather than the tokenizer.

This comment has been minimized.

Copy link
@ankon

ankon Mar 7, 2023

"specifiction" is a lovely portmanteau, but probably not what was wanted here :)

This comment has been minimized.

Copy link
@ianlancetaylor

ianlancetaylor Mar 7, 2023

Contributor

Thanks. We use Gerrit for code review, and very few people see comments on GitHub commits. If you want somebody to see this, please comment on https://go.dev/cl/459676. Or just send a patch. Thanks.

*/
package html // import "golang.org/x/net/html"

Expand Down

0 comments on commit 8c4ef2f

Please sign in to comment.