public T getExactPath(final String path) { return exactPathMatches.get(URLUtils.normalizeSlashes(path)); }
String encodedPart = encodedPath.substring(0, i); if (requiresDecode) { part = URLUtils.decode(encodedPart, charset, allowEncodedSlash,false, decodeBuffer); } else { part = encodedPart; final String qs = encodedPath.substring(i + 1); exchange.setQueryString(qs); URLUtils.parseQueryString(qs, exchange, charset, decode, maxParameters); return; } else if(c == ';') { String encodedPart = encodedPath.substring(0, i); if (requiresDecode) { part = URLUtils.decode(encodedPart, charset, allowEncodedSlash, false, decodeBuffer); } else { part = encodedPart; exchange.setRequestURI(encodedPath.substring(0, j)); String pathParams = encodedPath.substring(i + 1, j); URLUtils.parsePathParams(pathParams, exchange, charset, decode, maxParameters); String qs = encodedPath.substring(j + 1); exchange.setQueryString(qs); URLUtils.parseQueryString(qs, exchange, charset, decode, maxParameters); return; URLUtils.parsePathParams(encodedPath.substring(i + 1), exchange, charset, decode, maxParameters); return; } else if(c == '%' || c == '+') {
if (!decodeSlash && ((p1 == '2' && p2 == 'f') || (p1 == '5' && p2 == 'c'))) { if(pos + 2 >= bytes.length) { bytes = expandBytes(bytes); bytes = expandBytes(bytes); bytes = expandBytes(bytes); bytes = expandBytes(bytes); bytes[pos++] = (byte) (c >> 8); if (pos == bytes.length) { bytes = expandBytes(bytes);
/** * Decodes a URL. If the decoding fails for any reason then an IllegalArgumentException will be thrown. * * @param s The string to decode * @param enc The encoding * @param decodeSlash If slash characters should be decoded * @param buffer The string builder to use as a buffer. * @return The decoded URL */ public static String decode(String s, String enc, boolean decodeSlash, StringBuilder buffer) { return decode(s, enc, decodeSlash, true, buffer); }
exchange.setRelativePath(res); try { URLUtils.parsePathParams(result.value.substring(colon + 1), exchange, encoding, doDecode && result.containsUrlCharacters, maxParameters); } catch (ParameterLimitException e) { UndertowLogger.REQUEST_IO_LOGGER.failedToParseRequest(e); exchange.setQueryString(resultAsQueryString); try { URLUtils.parseQueryString(resultAsQueryString, exchange, encoding, doDecode && !decodingAlreadyDone, maxParameters); } catch (ParameterLimitException | IllegalArgumentException e) { UndertowLogger.REQUEST_IO_LOGGER.failedToParseRequest(e);
@Deprecated public static void parsePathParms(final String string, final HttpServerExchange exchange, final String charset, final boolean doDecode, int maxParameters) throws ParameterLimitException { parsePathParams(string, exchange, charset, doDecode, maxParameters); }
@Override public void sendRedirect(final String location) throws IOException { if (responseStarted()) { throw UndertowServletMessages.MESSAGES.responseAlreadyCommited(); } resetBuffer(); setStatus(StatusCodes.FOUND); String realPath; if (isAbsoluteUrl(location)) {//absolute url exchange.getResponseHeaders().put(Headers.LOCATION, location); } else { if (location.startsWith("/")) { realPath = location; } else { String current = exchange.getRelativePath(); int lastSlash = current.lastIndexOf("/"); if (lastSlash != -1) { current = current.substring(0, lastSlash + 1); } realPath = CanonicalPathUtils.canonicalize(servletContext.getContextPath() + current + location); } String loc = exchange.getRequestScheme() + "://" + exchange.getHostAndPort() + realPath; exchange.getResponseHeaders().put(Headers.LOCATION, loc); } responseDone(); }
private String decode(final String value, boolean urlDecodeRequired, ParseState state, final boolean allowEncodedSlash, final boolean formEncoded) { if (urlDecodeRequired) { return URLUtils.decode(value, charset, allowEncodedSlash, formEncoded, state.decodeBuffer); } else { return value; } }
exchange.setRelativePath(res); try { URLUtils.parsePathParams(result.value.substring(colon + 1), exchange, encoding, doDecode && result.containsUrlCharacters, maxParameters); } catch (ParameterLimitException e) { UndertowLogger.REQUEST_IO_LOGGER.failedToParseRequest(e); exchange.setQueryString(resultAsQueryString); try { URLUtils.parseQueryString(resultAsQueryString, exchange, encoding, doDecode && !decodingAlreadyDone, maxParameters); } catch (ParameterLimitException | IllegalArgumentException e) { UndertowLogger.REQUEST_IO_LOGGER.failedToParseRequest(e);
@Deprecated public static void parsePathParms(final String string, final HttpServerExchange exchange, final String charset, final boolean doDecode, int maxParameters) throws ParameterLimitException { parsePathParams(string, exchange, charset, doDecode, maxParameters); }
public synchronized PathMatcher addExactPath(final String path, final T handler) { if (path.isEmpty()) { throw UndertowMessages.MESSAGES.pathMustBeSpecified(); } exactPathMatches.put(URLUtils.normalizeSlashes(path), handler); return this; }
String encodedPart = encodedPath.substring(0, i); if (requiresDecode) { part = URLUtils.decode(encodedPart, charset, allowEncodedSlash,false, decodeBuffer); } else { part = encodedPart; final String qs = encodedPath.substring(i + 1); exchange.setQueryString(qs); URLUtils.parseQueryString(qs, exchange, charset, decode, maxParameters); return; } else if(c == ';') { String encodedPart = encodedPath.substring(0, i); if (requiresDecode) { part = URLUtils.decode(encodedPart, charset, allowEncodedSlash, false, decodeBuffer); } else { part = encodedPart; exchange.setRequestURI(encodedPath.substring(0, j)); String pathParams = encodedPath.substring(i + 1, j); URLUtils.parsePathParams(pathParams, exchange, charset, decode, maxParameters); String qs = encodedPath.substring(j + 1); exchange.setQueryString(qs); URLUtils.parseQueryString(qs, exchange, charset, decode, maxParameters); return; URLUtils.parsePathParams(encodedPath.substring(i + 1), exchange, charset, decode, maxParameters); return; } else if(c == '%' || c == '+') {
private String decode(String charset, String attrName, final boolean doDecode) throws UnsupportedEncodingException { if (doDecode) { return URLUtils.decode(attrName, charset, true, true, new StringBuilder()); } return attrName; }
exchange.setRelativePath(res); try { URLUtils.parsePathParams(result.value.substring(colon + 1), exchange, encoding, doDecode && result.containsUrlCharacters, maxParameters); } catch (ParameterLimitException e) { UndertowLogger.REQUEST_IO_LOGGER.failedToParseRequest(e); exchange.setQueryString(resultAsQueryString); try { URLUtils.parseQueryString(resultAsQueryString, exchange, encoding, doDecode && !decodingAlreadyDone, maxParameters); } catch (ParameterLimitException | IllegalArgumentException e) { UndertowLogger.REQUEST_IO_LOGGER.failedToParseRequest(e);
@Deprecated public static void parsePathParms(final String string, final HttpServerExchange exchange, final String charset, final boolean doDecode, int maxParameters) throws ParameterLimitException { parsePathParams(string, exchange, charset, doDecode, maxParameters); }
if (!decodeSlash && ((p1 == '2' && p2 == 'f') || (p1 == '5' && p2 == 'c'))) { if(pos + 2 >= bytes.length) { bytes = expandBytes(bytes); bytes = expandBytes(bytes); bytes = expandBytes(bytes); bytes = expandBytes(bytes); bytes[pos++] = (byte) (c >> 8); if (pos == bytes.length) { bytes = expandBytes(bytes);
public synchronized PathMatcher removeExactPath(final String path) { if (path == null || path.isEmpty()) { throw UndertowMessages.MESSAGES.pathMustBeSpecified(); } exactPathMatches.remove(URLUtils.normalizeSlashes(path)); return this; }
String encodedPart = encodedPath.substring(0, i); if (requiresDecode) { part = URLUtils.decode(encodedPart, charset, allowEncodedSlash,false, decodeBuffer); } else { part = encodedPart; final String qs = encodedPath.substring(i + 1); exchange.setQueryString(qs); URLUtils.parseQueryString(qs, exchange, charset, decode, maxParameters); return; } else if(c == ';') { String encodedPart = encodedPath.substring(0, i); if (requiresDecode) { part = URLUtils.decode(encodedPart, charset, allowEncodedSlash, false, decodeBuffer); } else { part = encodedPart; exchange.setRequestURI(encodedPath.substring(0, j)); String pathParams = encodedPath.substring(i + 1, j); URLUtils.parsePathParams(pathParams, exchange, charset, decode, maxParameters); String qs = encodedPath.substring(j + 1); exchange.setQueryString(qs); URLUtils.parseQueryString(qs, exchange, charset, decode, maxParameters); return; URLUtils.parsePathParams(encodedPath.substring(i + 1), exchange, charset, decode, maxParameters); return; } else if(c == '%' || c == '+') {
private String decode(String url, final boolean containsUrlCharacters) throws UnsupportedEncodingException { if (doDecode && containsUrlCharacters) { try { if(decodeBuffer == null) { decodeBuffer = new StringBuilder(); } return URLUtils.decode(url, this.encoding, allowEncodedSlash, false, decodeBuffer); } catch (Exception e) { throw UndertowMessages.MESSAGES.failedToDecodeURL(url, encoding, e); } } return url; }
if (!decodeSlash && ((p1 == '2' && p2 == 'f') || (p1 == '5' && p2 == 'c'))) { if(pos + 2 >= bytes.length) { bytes = expandBytes(bytes); bytes = expandBytes(bytes); bytes = expandBytes(bytes); bytes = expandBytes(bytes); bytes[pos++] = (byte) (c >> 8); if (pos == bytes.length) { bytes = expandBytes(bytes);