C# Class Tp.Web.Extensions.Components.Sanitizer

Clean up HTML code, remove dangerous fragments, such as styles, scripts, event attributes, forms, etc...
IDEA: Use HtmlTextWriter from the .NET framework to write resulting HTML code.
Datei anzeigen Open project: TargetProcess/Tp.HelpDesk Class Usage Examples

Protected Properties

Property Type Description
_enabled bool
_tags List

Public Methods

Method Description
Sanitize ( string input ) : string

Sanitize input HTML using default settings.

Sanitize ( TextReader input, TextWriter result ) : void
Sanitizer ( ) : System
TextToHtml ( string text ) : string

Protected Methods

Method Description
After ( TextWriter result ) : void
Before ( TextWriter result ) : void
CaseCData ( HtmlReader htmlReader, TextWriter result ) : void
CaseElement ( HtmlReader htmlReader, TextWriter result ) : void
CaseEndElement ( HtmlReader htmlReader, TextWriter result ) : void
CaseText ( HtmlReader htmlReader, TextWriter result ) : void
CheckStack ( ) : void
FuzzyPopTag ( string item ) : bool

Finds the specified tag somewhere in the stack and removes it from there.

IsValidAttribute ( string key, string value ) : bool
PopTag ( ) : string
Reset ( ) : void

Reset internal state left from previous run.

Sanitize ( HtmlReader htmlReader, TextWriter result ) : void
TopTag ( ) : string
WriteCData ( TextWriter result, string value ) : void
WriteElement ( TextWriter result, string name, StringDictionary attributes, bool empty ) : void
WriteEndElement ( TextWriter result, string name ) : void
WriteString ( TextWriter result, string value ) : void

Private Methods

Method Description
PushTag ( string item ) : void

Method Details

After() protected method

protected After ( TextWriter result ) : void
result System.IO.TextWriter
return void

Before() protected method

protected Before ( TextWriter result ) : void
result System.IO.TextWriter
return void

CaseCData() protected method

protected CaseCData ( HtmlReader htmlReader, TextWriter result ) : void
htmlReader HtmlReader
result System.IO.TextWriter
return void

CaseElement() protected method

protected CaseElement ( HtmlReader htmlReader, TextWriter result ) : void
htmlReader HtmlReader
result System.IO.TextWriter
return void

CaseEndElement() protected method

protected CaseEndElement ( HtmlReader htmlReader, TextWriter result ) : void
htmlReader HtmlReader
result System.IO.TextWriter
return void

CaseText() protected method

protected CaseText ( HtmlReader htmlReader, TextWriter result ) : void
htmlReader HtmlReader
result System.IO.TextWriter
return void

CheckStack() protected method

protected CheckStack ( ) : void
return void

FuzzyPopTag() protected method

Finds the specified tag somewhere in the stack and removes it from there.
protected FuzzyPopTag ( string item ) : bool
item string Item to remove.
return bool

IsValidAttribute() protected method

protected IsValidAttribute ( string key, string value ) : bool
key string
value string
return bool

PopTag() protected method

protected PopTag ( ) : string
return string

Reset() protected method

Reset internal state left from previous run.
protected Reset ( ) : void
return void

Sanitize() public static method

Sanitize input HTML using default settings.
public static Sanitize ( string input ) : string
input string Input HTML. May be null.
return string

Sanitize() protected method

protected Sanitize ( HtmlReader htmlReader, TextWriter result ) : void
htmlReader HtmlReader
result System.IO.TextWriter
return void

Sanitize() public method

public Sanitize ( TextReader input, TextWriter result ) : void
input TextReader
result System.IO.TextWriter
return void

Sanitizer() public method

public Sanitizer ( ) : System
return System

TextToHtml() public static method

public static TextToHtml ( string text ) : string
text string
return string

TopTag() protected method

protected TopTag ( ) : string
return string

WriteCData() protected method

protected WriteCData ( TextWriter result, string value ) : void
result System.IO.TextWriter
value string
return void

WriteElement() protected method

protected WriteElement ( TextWriter result, string name, StringDictionary attributes, bool empty ) : void
result System.IO.TextWriter
name string
attributes System.Collections.Specialized.StringDictionary
empty bool
return void

WriteEndElement() protected method

protected WriteEndElement ( TextWriter result, string name ) : void
result System.IO.TextWriter
name string
return void

WriteString() protected method

protected WriteString ( TextWriter result, string value ) : void
result System.IO.TextWriter
value string
return void

Property Details

_enabled protected_oe property

Whether to write elements.
protected bool _enabled
return bool

_tags protected_oe property

Stack with tags.
protected List _tags
return List