logoalt Hacker News

joshuahaglundtoday at 2:50 AM1 replyview on HN

Yeah "You can use newline or tab characters in the HREF attribute and the browser will throw a validation error, remove the offending character, try again, then succeed" would be a more accurate title.


Replies

shiomirutoday at 6:30 AM

Validation errors aren't really "exceptions" to be thrown, they are indicators for authors that something is probably wrong but they make no visible difference in the output. I'm not sure if any browser even tracks them (and if one did, the best it could do is complain in the dev tools).

Also, this is not limited to HREF, it's defined in URL[0] so you can also put newlines in new URL("...") etc.

[0]: https://url.spec.whatwg.org/#concept-basic-url-parser