Class LaxURLCodec

java.lang.Object
org.apache.commons.codec.net.URLCodec
org.archive.url.LaxURLCodec
All Implemented Interfaces:
org.apache.commons.codec.BinaryDecoder, org.apache.commons.codec.BinaryEncoder, org.apache.commons.codec.Decoder, org.apache.commons.codec.Encoder, org.apache.commons.codec.StringDecoder, org.apache.commons.codec.StringEncoder

public class LaxURLCodec extends org.apache.commons.codec.net.URLCodec
Author:
gojomo
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    static BitSet
    A more expansive set of ASCII URI characters to consider as 'safe' to leave unencoded, based on actual browser behavior.
    static BitSet
     

    Fields inherited from class org.apache.commons.codec.net.URLCodec

    charset, ESCAPE_CHAR, WWW_FORM_URL
  • Constructor Summary

    Constructors
    Constructor
    Description
    LaxURLCodec(String encoding)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static final byte[]
    decodeUrlLoose(byte[] bytes)
    Decodes an array of URL safe 7-bit characters into an array of original bytes.
    encode(BitSet safe, String pString, String cs)
    Encodes a string into its URL safe form using the specified string charset.

    Methods inherited from class org.apache.commons.codec.net.URLCodec

    decode, decode, decode, decode, decodeUrl, encode, encode, encode, encode, encodeUrl, getDefaultCharset, getEncoding

    Methods inherited from class java.lang.Object

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

    • DEFAULT

      public static LaxURLCodec DEFAULT
    • EXPANDED_URI_SAFE

      public static BitSet EXPANDED_URI_SAFE
      A more expansive set of ASCII URI characters to consider as 'safe' to leave unencoded, based on actual browser behavior.
    • QUERY_SAFE

      public static BitSet QUERY_SAFE
  • Constructor Details

    • LaxURLCodec

      public LaxURLCodec(String encoding)
  • Method Details

    • decodeUrlLoose

      public static final byte[] decodeUrlLoose(byte[] bytes)
      Decodes an array of URL safe 7-bit characters into an array of original bytes. Escaped characters are converted back to their original representation. Differs from URLCodec.decodeUrl() in that it throws no exceptions; bad or incomplete escape sequences are ignored and passed into result undecoded. This matches the behavior of browsers, which will use inconsistently-encoded URIs in HTTP request-lines.
      Parameters:
      bytes - array of URL safe characters
      Returns:
      array of original bytes
    • encode

      public String encode(BitSet safe, String pString, String cs) throws UnsupportedEncodingException
      Encodes a string into its URL safe form using the specified string charset. Unsafe characters are escaped. This method is analogous to superclass encode() methods, additionally offering the ability to specify a different 'safe' character set (such as EXPANDED_URI_SAFE).
      Parameters:
      safe - BitSet of characters that don't need to be encoded
      pString - String to encode
      cs - Name of character set to use
      Returns:
      Encoded version of pString.
      Throws:
      UnsupportedEncodingException