org.archive.net
Class LaxURLCodec

java.lang.Object
  extended by org.apache.commons.codec.net.URLCodec
      extended by org.archive.net.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
static LaxURLCodec DEFAULT
           
static java.util.BitSet EXPANDED_URI_SAFE
          A more expansive set of ASCII URI characters to consider as 'safe' to leave unencoded, based on actual browser behavior.
static java.util.BitSet QUERY_SAFE
           
 
Fields inherited from class org.apache.commons.codec.net.URLCodec
charset, ESCAPE_CHAR, WWW_FORM_URL
 
Constructor Summary
LaxURLCodec(java.lang.String encoding)
           
 
Method Summary
static byte[] decodeUrlLoose(byte[] bytes)
          Decodes an array of URL safe 7-bit characters into an array of original bytes.
 java.lang.String encode(java.util.BitSet safe, java.lang.String pString, java.lang.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 Detail

DEFAULT

public static LaxURLCodec DEFAULT

EXPANDED_URI_SAFE

public static java.util.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 java.util.BitSet QUERY_SAFE
Constructor Detail

LaxURLCodec

public LaxURLCodec(java.lang.String encoding)
Method Detail

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 java.lang.String encode(java.util.BitSet safe,
                               java.lang.String pString,
                               java.lang.String cs)
                        throws java.io.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:
java.io.UnsupportedEncodingException


Copyright © 2003-2011 Internet Archive. All Rights Reserved.