Closed hansede closed 2 months ago
According to the official HTML spec, HTML escape sequences must end with a semicolon (;) character:
This is the case in order to be "valid HTML". However, character references without semicolons do work (as in, they have specified parsing behavior), just with an error: https://html.spec.whatwg.org/multipage/parsing.html#parse-error-missing-semicolon-after-character-reference
It sounds like you want the strict
option: https://github.com/mathiasbynens/he#strict-1
Oof, it's frustrating that the section you linked about the semicolon parsing error invalidates the rather concrete statement about semicolons in the "character references" section, and without being referenced in the "character references" section. You are correct though, and I'll use the strict
option instead.
he
version:1.2.0
.According to the official HTML spec, HTML escape sequences must end with a semicolon (
;
) character:https://html.spec.whatwg.org/multipage/syntax.html#character-references
However,
he.decode
doesn't account for the presence of a semicolon, leading to the following behavior:Instead, I would expect the following:
This led to a production issue in my application where Google Maps URLs, which include an
¢er
query param, were being decoded with¢er
as a query param instead, breaking maps on my pages.