Clean up documentation
This commit is contained in:
@@ -2202,8 +2202,7 @@ rl(javascript:alert(""foo""))'>";
|
||||
|
||||
// Act
|
||||
var htmlFragment = "Тест";
|
||||
//var outputFormatter = new CsQuery.Output.FormatDefault(DomRenderingOptions.RemoveComments | DomRenderingOptions.QuoteAllAttributes, HtmlEncoders.Minimum);
|
||||
var actual = s.Sanitize(htmlFragment, ""/*, outputFormatter*/);
|
||||
var actual = s.Sanitize(htmlFragment, "");
|
||||
|
||||
// Assert
|
||||
var expected = htmlFragment;
|
||||
|
||||
@@ -14,10 +14,10 @@ using System.Text.RegularExpressions;
|
||||
namespace Ganss.XSS
|
||||
{
|
||||
/// <summary>
|
||||
/// Cleans HTML fragments from constructs that can lead to <a href="https://en.wikipedia.org/wiki/Cross-site_scripting">XSS attacks</a>.
|
||||
/// Cleans HTML documents and fragments from constructs that can lead to <a href="https://en.wikipedia.org/wiki/Cross-site_scripting">XSS attacks</a>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// XSS attacks can occur at several levels within an HTML fragment:
|
||||
/// XSS attacks can occur at several levels within an HTML document or fragment:
|
||||
/// <list type="bullet">
|
||||
/// <item>HTML Tags (e.g. the <script> tag)</item>
|
||||
/// <item>HTML attributes (e.g. the "onload" attribute)</item>
|
||||
@@ -25,8 +25,7 @@ namespace Ganss.XSS
|
||||
/// <item>malformed HTML or HTML that exploits parser bugs in specific browsers</item>
|
||||
/// </list>
|
||||
/// <para>
|
||||
/// The HtmlSanitizer class addresses all of these possible attack vectors by using an HTML parser that is based on the one used
|
||||
/// in the Gecko browser engine (see <a href="https://github.com/jamietre/CsQuery">CsQuery</a>).
|
||||
/// The HtmlSanitizer class addresses all of these possible attack vectors by using a sophisticated HTML parser (<a href="https://github.com/AngleSharp/AngleSharp">AngleSharp</a>).
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// In order to facilitate different use cases, HtmlSanitizer can be customized at the levels mentioned above:
|
||||
|
||||
@@ -6,41 +6,9 @@ using System.Text.RegularExpressions;
|
||||
namespace Ganss.XSS
|
||||
{
|
||||
/// <summary>
|
||||
/// Cleans HTML fragments from constructs that can lead to <a href="https://en.wikipedia.org/wiki/Cross-site_scripting">XSS attacks</a>.
|
||||
/// Enables an inheriting class to implement an HtmlSanitizer class, which cleans HTML documents and fragments
|
||||
/// from constructs that can lead to <a href="https://en.wikipedia.org/wiki/Cross-site_scripting">XSS attacks</a>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// XSS attacks can occur at several levels within an HTML fragment:
|
||||
/// <list type="bullet">
|
||||
/// <item>HTML Tags (e.g. the <script> tag)</item>
|
||||
/// <item>HTML attributes (e.g. the "onload" attribute)</item>
|
||||
/// <item>CSS styles (url property values)</item>
|
||||
/// <item>malformed HTML or HTML that exploits parser bugs in specific browsers</item>
|
||||
/// </list>
|
||||
/// <para>
|
||||
/// The HtmlSanitizer class addresses all of these possible attack vectors by using an HTML parser that is based on the one used
|
||||
/// in the Gecko browser engine (see <a href="https://github.com/jamietre/CsQuery">CsQuery</a>).
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// In order to facilitate different use cases, HtmlSanitizer can be customized at the levels mentioned above:
|
||||
/// <list type="bullet">
|
||||
/// <item>You can specify the allowed HTML tags through the property <see cref="AllowedTags"/>. All other tags will be stripped.</item>
|
||||
/// <item>You can specify the allowed HTML attributes through the property <see cref="AllowedAttributes"/>. All other attributes will be stripped.</item>
|
||||
/// <item>You can specify the allowed CSS property names through the property <see cref="AllowedCssProperties"/>. All other styles will be stripped.</item>
|
||||
/// <item>You can specify the allowed URI schemes through the property <see cref="AllowedCssProperties"/>. All other URIs will be stripped.</item>
|
||||
/// <item>You can specify the HTML attributes that contain URIs (such as "src", "href" etc.) through the property <see cref="UriAttributes"/>.</item>
|
||||
/// </list>
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// <![CDATA[
|
||||
/// var sanitizer = new HtmlSanitizer();
|
||||
/// var html = @"<script>alert('xss')</script><div onload=""alert('xss')"" style=""background-color: test"">Test<img src=""test.gif"" style=""background-image: url(javascript:alert('xss')); margin: 10px""></div>";
|
||||
/// var sanitized = sanitizer.Sanitize(html, "http://www.example.com");
|
||||
/// // -> "<div style="background-color: test">Test<img style="margin: 10px" src="http://www.example.com/test.gif"></div>"
|
||||
/// ]]>
|
||||
/// </code>
|
||||
/// </example>
|
||||
public interface IHtmlSanitizer
|
||||
{
|
||||
/// <summary>
|
||||
@@ -121,7 +89,7 @@ namespace Ganss.XSS
|
||||
/// </summary>
|
||||
/// <param name="html">The HTML to sanitize.</param>
|
||||
/// <param name="baseUrl">The base URL relative URLs are resolved against. No resolution if empty.</param>
|
||||
/// <param name="outputFormatter">The CsQuery output formatter used to render the DOM. Using the default formatter if null.</param>
|
||||
/// <param name="outputFormatter">The formatter used to render the DOM. Using the default formatter if null.</param>
|
||||
/// <returns>The sanitized HTML.</returns>
|
||||
string Sanitize(string html, string baseUrl = "", IMarkupFormatter outputFormatter = null);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ HtmlSanitizer
|
||||
[](https://ci.appveyor.com/project/mganss/htmlsanitizer/branch/master)
|
||||
[](https://codecov.io/github/mganss/HtmlSanitizer?branch=master)
|
||||
|
||||
HtmlSanitizer is a .NET library for cleaning HTML fragments from constructs that can lead to [XSS attacks](https://en.wikipedia.org/wiki/Cross-site_scripting).
|
||||
HtmlSanitizer is a .NET library for cleaning HTML fragments and documents from constructs that can lead to [XSS attacks](https://en.wikipedia.org/wiki/Cross-site_scripting).
|
||||
It uses [AngleSharp](https://github.com/AngleSharp/AngleSharp) to parse, manipulate, and render HTML and CSS.
|
||||
|
||||
Because HtmlSanitizer is based on a robust HTML parser it can also shield you from deliberate or accidental
|
||||
|
||||
Reference in New Issue
Block a user