@StableMinor(version="12.3", sinceVersion="4.0") public abstract class HtmlUtil extends Object
Constructor and Description |
---|
HtmlUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
decode(String inputHtml)
Decodes a HTML string, replacing character references (&...;) by their
corresponding characters.
|
static String |
encode(String inputHtml)
Encodes a HTML string, replacing extended characters by their
corresponding character references.
|
static String |
encode(String inputHtml,
boolean useEntityRefs)
Encodes a HTML string, replacing extended caracters by their
corresponding character references if the parameter
useEntityRefs
is true |
static String |
fixInvalidHtmlPattern(String inputHtml)
Parses the input HTML string, fixes any invalid HTML patterns and returns the fixed result.
|
static void |
validateJSFragmentSafety(String jsFragment)
Validates if a javascript code fragment is safe to be injected in a page.
|
public static String decode(String inputHtml)
e.g: coração -> coração
For more information about HTML character references, see the section "5.3 Character references" of the HTML 4.01 Specification
inputHtml
- input HTMLpublic static String encode(String inputHtml)
e.g: coração -> coração
For more information about HTML character references, see the section "5.3 Character references" of the HTML 4.01 Specification
inputHtml
- the string to be encoded.public static String encode(String inputHtml, boolean useEntityRefs)
useEntityRefs
is true
e.g: coração -> coração
else the replacement is done using the decimal reference
e.g: coração -> coração
For more information about HTML character references, see the section "5.3 Character references" of the HTML 4.01 Specification
inputHtml
- the string to be encoded.useEntityRefs
- if HTML entities should be used during encoding.public static String fixInvalidHtmlPattern(String inputHtml)
input
- HTML to be fixedpublic static void validateJSFragmentSafety(String jsFragment)
Currently this method accepts code that contains only letters, numbers, underscore or period. These can be used to represent an object reference.
jsFragment
- the javascript code fragment.IllegalArgumentException
- if the javascript code fragment is
considered unsafe.LumisXP 12.3.0.200408 - Copyright © 2006–2020 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.