Interface IHtmlService
Interface representing a service for processing Html content
Namespace: DataWeb.Text.Html
Assembly: DataWeb.Core.dll
Syntax
public interface IHtmlService
Properties
Name
Gets the name of the Html service
Declaration
string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
ConvertToText(string)
Converts Html content to plain text
Declaration
string ConvertToText(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The Html content to convert |
Returns
| Type | Description |
|---|---|
| string | The plain text representation of the Html content |
IsSafeSvg(string)
Checks if an SVG string is safe by ensuring it does not contain potentially dangerous elements or attributes.
Declaration
bool IsSafeSvg(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The SVG content to be checked. |
Returns
| Type | Description |
|---|---|
| bool | True if the SVG is safe, otherwise false. |
IsSvg(string)
Checks whether the given string is a valid SVG.
Declaration
bool IsSvg(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The string containing the potential SVG content. |
Returns
| Type | Description |
|---|---|
| bool | True if the string is a well-formed XML and its root element is <svg>, otherwise false. |
RemoveInvalidHtmlTags(string)
Removes invalid Html tags from the provided string
Declaration
string RemoveInvalidHtmlTags(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The string to process |
Returns
| Type | Description |
|---|---|
| string | The processed string with invalid Html tags removed |
ReplaceHtmlEntities(string)
Replaces Html entities in the provided string
Declaration
string ReplaceHtmlEntities(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The string to process |
Returns
| Type | Description |
|---|---|
| string | The processed string with Html entities replaced |
SanitizeSvg(string)
Sanitizes an SVG string by removing potentially dangerous elements and attributes to prevent XSS attacks.
Declaration
string SanitizeSvg(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The SVG content to be sanitized. |
Returns
| Type | Description |
|---|---|
| string | The sanitized SVG string, free from harmful tags and attributes. |
StripHtml(string)
Strips Html tags from the provided string
Declaration
string StripHtml(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The string to process |
Returns
| Type | Description |
|---|---|
| string | The processed string with all Html tags removed |