2362N/A * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Utility class for HTML form decoding. This class contains static methods 0N/A * The conversion process is the reverse of that used by the URLEncoder class. It is assumed 0N/A * that all characters in the encoded string are one of the following: 0N/A * "<code>a</code>" through "<code>z</code>", 0N/A * "<code>A</code>" through "<code>Z</code>", 0N/A * "<code>0</code>" through "<code>9</code>", and 0N/A * "<code>-</code>", "<code>_</code>", 0N/A * "<code>.</code>", and "<code>*</code>". The 0N/A * character "<code>%</code>" is allowed but is interpreted 0N/A * as the start of a special escaped sequence. 0N/A * The following rules are applied in the conversion: 0N/A * <li>The alphanumeric characters "<code>a</code>" through 0N/A * "<code>z</code>", "<code>A</code>" through 0N/A * "<code>Z</code>" and "<code>0</code>" 0N/A * through "<code>9</code>" remain the same. 0N/A * <li>The special characters "<code>.</code>", 0N/A * "<code>-</code>", "<code>*</code>", and 0N/A * "<code>_</code>" remain the same. 0N/A * <li>The plus sign "<code>+</code>" is converted into a 0N/A * space character "<code> </code>" . 0N/A * <li>A sequence of the form "<code>%<i>xy</i></code>" will be 0N/A * treated as representing a byte where <i>xy</i> is the two-digit 0N/A * hexadecimal representation of the 8 bits. Then, all substrings 0N/A * that contain one or more of these byte sequences consecutively 0N/A * will be replaced by the character(s) whose encoding would result 0N/A * in those consecutive bytes. 0N/A * The encoding scheme used to decode these characters may be specified, 0N/A * or if unspecified, the default encoding of the platform will be used. 0N/A * There are two possible ways in which this decoder could deal with 0N/A * illegal strings. It could either leave illegal characters alone or 0N/A * it could throw an <tt>{@link java.lang.IllegalArgumentException}</tt>. 0N/A * Which approach the decoder takes is left to the 0N/A * @author Mark Chamness 0N/A * @author Michael McCloskey 0N/A // The platform default encoding 0N/A * Decodes a <code>x-www-form-urlencoded</code> string. 0N/A * The platform's default encoding is used to determine what characters 0N/A * are represented by any consecutive sequences of the form 0N/A * "<code>%<i>xy</i></code>". 0N/A * @param s the <code>String</code> to decode 0N/A * @deprecated The resulting string may vary depending on the platform's 0N/A * default encoding. Instead, use the decode(String,String) method 0N/A * to specify the encoding. 0N/A * @return the newly decoded <code>String</code> 0N/A // The system should always have the platform default 0N/A * The supplied encoding is used to determine 0N/A * what characters are represented by any consecutive sequences of the 0N/A * form "<code>%<i>xy</i></code>". 0N/A * <em><strong>Note:</strong> The <a href= 0N/A * World Wide Web Consortium Recommendation</a> states that 0N/A * UTF-8 should be used. Not doing so may introduce 0N/A * incompatibilites.</em> 0N/A * @param s the <code>String</code> to decode 0N/A * @param enc The name of a supported 0N/A * @return the newly decoded <code>String</code> 0N/A * @exception UnsupportedEncodingException 0N/A * If character encoding needs to be consulted, but 0N/A * named character encoding is not supported 0N/A * @see URLEncoder#encode(java.lang.String, java.lang.String) 0N/A * Starting with this instance of %, process all 0N/A * consecutive substrings of the form %xy. Each 0N/A * substring %xy will yield a byte. Convert all 0N/A * consecutive bytes obtained this way to whatever 0N/A * character(s) they represent in the provided 0N/A // (numChars-i)/3 is an upper bound for the number 0N/A // of remaining bytes 0N/A // A trailing, incomplete byte encoding such as 0N/A // "%x" will cause an exception to be thrown 0N/A "URLDecoder: Incomplete trailing escape (%) pattern");
0N/A "URLDecoder: Illegal hex characters in escape (%) pattern - "