org.activemath.webapp.view.tools
Class EscapeTool

java.lang.Object
  extended by org.activemath.webapp.view.tools.EscapeTool

public class EscapeTool
extends Object

Escape tool for replacing special characters for different formats.


Constructor Summary
EscapeTool(AppModel appModel)
           
 
Method Summary
static String forHtml(String input)
          Escape characters for Javascript, i.e. escape single and double quotes.
static String forHtmlSafety(String input)
          Escape characters for text appearing in HTML markup.
static String forJs(String input)
          Escape characters for Javascript, i.e. escape single and double quotes, and newlines The following characters are replaced: Character Encoding " \" ' \' \n
 String forLatex(String input)
           
static String forXml(String input)
          Escape characters for text appearing as XML data, between tags.
static void main(String[] args)
           
static String toDisableTags(String input)
          Return aText with all '<' and '>' characters replaced by their escaped equivalents.
 String toLatex(String input)
          Deprecated. Use forLatex()
 String toXMLText(String input)
          Deprecated. Use forXML()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EscapeTool

public EscapeTool(AppModel appModel)
Method Detail

toXMLText

public String toXMLText(String input)
Deprecated. Use forXML()


forHtml

public static String forHtml(String input)
Escape characters for Javascript, i.e. escape single and double quotes.

The following characters are replaced:

Character Encoding
" "
' '


forJs

public static String forJs(String input)
Escape characters for Javascript, i.e. escape single and double quotes, and newlines

The following characters are replaced:

Character Encoding
" \"
' \'
\n


forXml

public static String forXml(String input)
Escape characters for text appearing as XML data, between tags.

The following characters are replaced with corresponding character entities :

Character Encoding
< <
> >
& &
" "
' '


forHtmlSafety

public static String forHtmlSafety(String input)
Escape characters for text appearing in HTML markup.

This method exists as a defence against Cross Site Scripting (XSS) hacks. This method escapes all characters recommended by the Open Web App Security Project - link.

The following characters are replaced with corresponding HTML character entities :

Character Encoding
< <
> >
& &
" "
' '
( (
) )
# #
% %
; ;
+ +
- -


toDisableTags

public static String toDisableTags(String input)
Return aText with all '<' and '>' characters replaced by their escaped equivalents.


toLatex

public String toLatex(String input)
Deprecated. Use forLatex()


forLatex

public String forLatex(String input)

main

public static void main(String[] args)