HTML sanitization: Difference between revisions

Content deleted Content added
No edit summary
m fix duplicate unnamed reference
Line 6:
Sanitization is typically performed by using either a [[whitelist]] or a [[Blacklist (computing)|blacklist]] approach. Leaving a safe HTML element off a whitelist is not so serious; it simply means that that feature will not be included post-sanitation. On the other hand, if an unsafe element is left off a blacklist, then the vulnerability will not be sanitized out of the HTML output. An out-of-date blacklist can therefore be dangerous if new, unsafe features have been introduced to the HTML Standard.
 
Further sanitization can be performed based on rules which specify what operation is to be performed on the subject tags. Typical operations include removal of the tag itself while preserving the content, preserving only the textual content of a tag or forcing certain values on attributes.<ref name="HtmlRuleSanitizer">https://github.com/Vereyon/HtmlRuleSanitizer</ref>
 
== Implementations ==
Line 14:
In [[Java (programming language)|Java]] (and [[.NET Framework|.NET]]), sanitization can be achieved by using the [[OWASP]] Java HTML Sanitizer Project.<ref>https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer_Project</ref>
 
In [[.NET Framework|.NET]], a number of sanitizers use the Html Agility Pack, an HTML parser.<ref>http://htmlagilitypack.codeplex.com/</ref><ref>http://eksith.wordpress.com/2011/06/14/whitelist-santize-htmlagilitypack/</ref><ref>https://github.com/Vereyon/ name="HtmlRuleSanitizer<" /ref>
 
In [[JavaScript]] there are "JS-only" sanitizers for the [[Front_and_back_ends|back end]], and browser-based<ref>https://github.com/jitbit/HtmlSanitizer</ref> implementations that use browser's own DOM parser to parse the HTML (for better performance).