/** * Decode and return the specified URL-encoded String. It is assumed the * string is not a query string. * * @param str The url-encoded string * @param enc The encoding to use; if null, the default encoding is used * @exception IllegalArgumentException if a '%' character is not followed * by a valid 2-digit hexadecimal number */ public static String URLDecode(String str, String enc) { return URLDecode(str, enc, false); }
/** * Normalize a relative URI path that may have relative values ("/./", * "/../", and so on ) it it. <strong>WARNING</strong> - This method is * useful only for normalizing application-generated paths. It does not * try to perform security checks for malicious input. * * @param path Relative path to be normalized */ public static String normalize(String path) { return normalize(path, true); }
value = new String(data, 0, ox, encoding); if (key != null) { putMapEntry(map, key, value); key = null; break; case '%': data[ox++] = (byte)((convertHexDigit(data[ix++]) << 4) + convertHexDigit(data[ix++])); break; default: putMapEntry(map, key, value);
protected static boolean validateContextName(ContextName cn, PrintWriter writer, StringManager sm) { // ContextName should be non-null with a path that is empty or starts // with / if (cn != null && (cn.getPath().startsWith("/") || cn.getPath().equals(""))) { return true; } String path = null; if (cn != null) { path = RequestUtil.filter(cn.getPath()); } writer.println(sm.getString("managerServlet.invalidPath", path)); return false; }
parseParameters(map, bytes, encoding);
b = (byte)' '; } else if (b == '%') { b = (byte) ((convertHexDigit(bytes[ix++]) << 4) + convertHexDigit(bytes[ix++]));
value = new String(data, 0, ox, Charsets.lookupCharset(encoding)); if (key != null) { putMapEntry(map, key, value); key = null; putMapEntry(map, key, value);
value = new String(data, 0, ox, encoding); if (key != null) { putMapEntry(map, key, value); key = null; break; case '%': data[ox++] = (byte)((convertHexDigit(data[ix++]) << 4) + convertHexDigit(data[ix++])); break; default: putMapEntry(map, key, value);
protected static boolean validateContextName(ContextName cn, PrintWriter writer, StringManager sm) { // ContextName should be non-null with a path that is empty or starts // with / if (cn != null && (cn.getPath().startsWith("/") || cn.getPath().equals(""))) { return true; } String path = null; if (cn != null) { path = RequestUtil.filter(cn.getPath()); } writer.println(sm.getString("managerServlet.invalidPath", path)); return false; }
parseParameters(map, bytes, encoding);
b = (byte)' '; } else if (b == '%') { b = (byte) ((convertHexDigit(bytes[ix++]) << 4) + convertHexDigit(bytes[ix++]));
value = new String(data, 0, ox, encoding); if (key != null) { putMapEntry(map, key, value); key = null; break; case '%': data[ox++] = (byte)((convertHexDigit(data[ix++]) << 4) + convertHexDigit(data[ix++])); break; default: putMapEntry(map, key, value);
protected static boolean validateContextName(ContextName cn, PrintWriter writer, StringManager sm) { // ContextName should be non-null with a path that is empty or starts // with / if (cn != null && (cn.getPath().startsWith("/") || cn.getPath().equals(""))) { return true; } String path = null; if (cn != null) { path = RequestUtil.filter(cn.getPath()); } writer.println(sm.getString("managerServlet.invalidPath", path)); return false; }
parseParameters(map, bytes, encoding);
/** * Set the location. * * @param location The new location */ public void setLocation(String location) { // if ((location == null) || !location.startsWith("/")) // throw new IllegalArgumentException // ("Error Page Location must start with a '/'"); this.location = RequestUtil.URLDecode(location); }
/** * Return a context-relative path, beginning with a "/", that represents * the canonical version of the specified path after ".." and "." elements * are resolved out. If the specified path attempts to go outside the * boundaries of the current context (i.e. too many ".." path elements * are present), return <code>null</code> instead. * * @param path Path to be normalized */ protected String normalize(String path) { return RequestUtil.normalize(path, File.separatorChar == '\\'); }
throw new IllegalArgumentException("%xx URL decode missing digit"); b = (byte) ((convertHexDigit(bytes[ix++]) << 4) + convertHexDigit(bytes[ix++]));
value = new String(data, 0, ox, encoding); if (key != null) { putMapEntry(map, key, value); key = null; break; case '%': data[ox++] = (byte)((convertHexDigit(data[ix++]) << 4) + convertHexDigit(data[ix++])); break; default: putMapEntry(map, key, value);
protected static boolean validateContextName(ContextName cn, PrintWriter writer, StringManager sm) { // ContextName should be non-null with a path that is empty or starts // with / if (cn != null && (cn.getPath().startsWith("/") || cn.getPath().equals(""))) { return true; } String path = null; if (cn != null) { path = RequestUtil.filter(cn.getPath()); } writer.println(sm.getString("managerServlet.invalidPath", path)); return false; }
/** * Merge the parameters from the saved query parameter string (if any), and * the parameters already present on this request (if any), such that the * parameter values from the query string show up first if there are * duplicate parameter names. */ private void mergeParameters() { if ((queryParamString == null) || (queryParamString.length() < 1)) return; HashMap<String, String[]> queryParameters = new HashMap<>(); String encoding = getCharacterEncoding(); if (encoding == null) encoding = "ISO-8859-1"; RequestUtil.parseParameters(queryParameters, queryParamString, encoding); Iterator<String> keys = parameters.keySet().iterator(); while (keys.hasNext()) { String key = keys.next(); Object value = queryParameters.get(key); if (value == null) { queryParameters.put(key, parameters.get(key)); continue; } queryParameters.put (key, mergeValues(value, parameters.get(key))); } parameters = queryParameters; }