Class Escaper

java.lang.Object
com.zfabrik.util.html.Escaper

public class Escaper extends Object
Various encoding and decoding utility functions.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Escape a string to be used as an HTML String literal
    static String
    Escape a string to be used as a Javascript String literal.
    static String
    Escape a string to be used as a JSON String literal.
    static String
    URL encode/decode This implementation helps addressing two things: As Apache's mod_proxy unfortunately (and almost utterly incomprehensibly) unescapes URLs before passing them on to the backend, you can use this method to use an alternative character (e.g.
    static String
    urlDecode(String in, char esc)
    URL encode/decode This implementation helps addressing two things: As Apache's mod_proxy unfortunately (and almost utterly incomprehensibly) unescapes URLs before passing them on to the backend, you can use this method to use an alternative character (e.g.
    static String
    URL encode/decode This implementation helps addressing two things: As Apache's mod_proxy unfortunately (and almost utterly incomprehensibly) unescapes URLs before passing them on to the backend, you can use this method to use an alternative character (e.g.
    static String
    urlEncode(String in, char esc)
    URL encode/decode This implementation helps addressing two things: As Apache's mod_proxy unfortunately (and almost utterly incomprehensibly) unescapes URLs before passing them on to the backend, you can use this method to use an alternative character (e.g.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Escaper

      public Escaper()
  • Method Details

    • escapeToJSON

      public static String escapeToJSON(String in)
      Escape a string to be used as a JSON String literal.
    • escapeToJS

      public static String escapeToJS(String in)
      Escape a string to be used as a Javascript String literal.
    • escapeToHTML

      public static String escapeToHTML(String in)
      Escape a string to be used as an HTML String literal
    • urlEncode

      public static String urlEncode(String in, char esc)
      URL encode/decode This implementation helps addressing two things:
      • As Apache's mod_proxy unfortunately (and almost utterly incomprehensibly) unescapes URLs before passing them on to the backend, you can use this method to use an alternative character (e.g. "!") rather than "%" as escape character.
      • Using this method, you can spare catching UnsupportedEncodingExceptions, that are never thrown or you'd be in much bigger trouble anyway. This method always uses utf-8 encoding.
    • urlEncode

      public static String urlEncode(String in)
      URL encode/decode This implementation helps addressing two things:
      • As Apache's mod_proxy unfortunately (and almost utterly incomprehensibly) unescapes URLs before passing them on to the backend, you can use this method to use an alternative character (e.g. "!") rather than "%" as escape character.
      • Using this method, you can spare catching UnsupportedEncodingExceptions, that are never thrown or you'd be in much bigger trouble anyway. This method always uses utf-8 encoding.
    • urlDecode

      public static String urlDecode(String in, char esc)
      URL encode/decode This implementation helps addressing two things:
      • As Apache's mod_proxy unfortunately (and almost utterly incomprehensibly) unescapes URLs before passing them on to the backend, you can use this method to use an alternative character (e.g. "!") rather than "%" as escape character.
      • Using this method, you can spare catching UnsupportedEncodingExceptions, that are never thrown or you'd be in much bigger trouble anyway. This method always uses utf-8 encoding.
    • urlDecode

      public static String urlDecode(String in)
      URL encode/decode This implementation helps addressing two things:
      • As Apache's mod_proxy unfortunately (and almost utterly incomprehensibly) unescapes URLs before passing them on to the backend, you can use this method to use an alternative character (e.g. "!") rather than "%" as escape character.
      • Using this method, you can spare catching UnsupportedEncodingExceptions, that are never thrown or you'd be in much bigger trouble anyway. This method always uses utf-8 encoding.