3 ms·
Now that html5 defines how to parse all html fragments there is really no reason not to use that algorithm.
by justincormack 15y ago
Now that html5 defines how to parse all html fragments there is really no reason not to use that algorithm.
- arkitaip 15y agoYou're assuming that web sites consist of compliant html; which is never the case.
- AndrewDucker 15y agoThe HTML5 parsing algorithm states how to parse invalid HTML.
- masklinn 15y agoThe HTML5 parsing algorithm was designed to standardize parsing of real-world pages, including error recovery (for invalid and/or legacy markup), that's the whole bloody point of it. Better, using an implementation of the HTML5 parsing algorithm means you're parsing pages the same way browsers do: Gecko (Firefox), Webkit (Chrome and Safari) and Presto (Opera) have all landed the HTML5 parsing algorithm, and Trident (IE) is in the process of getting it (the feature is planned for IE10's Trident 6.0)
- gambler 15y agoCould you provide some working examples of using HTML 5 parser for input sanitization?
- justincormack 15y agohttp://code.google.com/p/html5lib/ http://code.google.com/p/html5lib/
- gambler 15y agoI see that they mention sanitizer and give an example of how to call it, but I can't find any real-life code doing sanitization. Am I missing something? (I'm curious about the level of complexity such library would require in 'client' code.)
- hoppipolla 15y agoBleach [1] is a sanitizer that uses html5lib on the backend. I think that Mozilla use it. [1] http://pypi.python.org/pypi/bleach http://pypi.python.org/pypi/bleach