Enum lol_html::html_content::TextType
source · pub enum TextType {
PlainText,
RCData,
RawText,
ScriptData,
Data,
CDataSection,
}
Expand description
A type of parsed text.
Parsing context adds certain limitations for the textual content. E.g., it’s unsafe to
rewrite text inside <script>
element with a string that contains "</script>"
substring as
this will preemptively close the <script>
element, possibly introducing an XSS attack vector.
As other example, some parsing contexts don’t allow HTML entities in text. Thus, rewriting
content of a <style>
element with text that contains HTML entities may cause a CSS parsing
error in a browser, because entities won’t be decoded by a browser in this context.
Text type provides users of the rewriter with a capability to assess the context in which text parsing is hapenning and make informed decision about preprocessing of the textual content replacement.
The names of the text types are taken from the HTML parsing specification.
Variants§
PlainText
Text inside a <plaintext>
element.
RCData
Text inside <title>
and <textarea>
elements.
RawText
Text inside <style>
, <xmp>
, <iframe>
, <noembed>
, <noframes>
and
<noscript>
elements.
ScriptData
Text inside a <script>
element.
Data
Regular text.
CDataSection
Text inside a CDATA section.