lumis.util
Class HtmlUtil

Package class diagram package HtmlUtil
java.lang.Object
  extended by lumis.util.HtmlUtil

@StableMinor(version="5.5",
             sinceVersion="4.0")
public abstract class HtmlUtil
extends Object

Utility class for HTML decoding

Since:
4.0.0

Constructor Summary
HtmlUtil()
           
 
Method Summary
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)
           
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlUtil

public HtmlUtil()
Method Detail

decode

public static String decode(String inputHtml)
Decodes a HTML string, replacing character references (&...;) by their corresponding characters.

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

Parameters:
inputHtml - input HTML
Returns:
the HTML decoded

encode

public static String encode(String inputHtml)
Encodes a HTML string, replacing extended characters by their corresponding character references.

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

Parameters:
inputHtml - input HTML
Returns:
the HTML encoded

encode

public static String encode(String inputHtml,
                            boolean useEntityRefs)

fixInvalidHtmlPattern

public static String fixInvalidHtmlPattern(String inputHtml)
Parses the input HTML string, fixes any invalid HTML patterns and returns the fixed result.

Parameters:
input - HTML to be fixed
Returns:
the fixed HTML
Since:
4.1.1

validateJSFragmentSafety

public static void validateJSFragmentSafety(String jsFragment)
Validates if a javascript code fragment is safe to be injected in a page. This method is to be used when javascript codes are obtained from unsecure sources, such as a HTTP request parameter.

Currently this method accepts code that contains only letters, numbers, underscore or period. These can be used to represent an object reference.

Parameters:
jsFragment - the javascript code fragment.
Throws:
IllegalArgumentException - if the javascript code fragment is considered unsafe.
Since:
5.0.0


Lumisportal  5.5.0.091130 - Copyright © 2001-2007, Lumis. All Rights Reserved.