private void parse(URI uri) { try { String query = uri.getQuery();
private String getPathRegex(URI uri) throws URIException { URI newUri; // ZAP: catch CloneNotSupportedException as introduced with version 3.1 of HttpClient try { newUri = (URI) uri.clone(); } catch (CloneNotSupportedException e) { throw new URIException(e.getMessage()); } String query = newUri.getQuery(); StringBuilder sb = new StringBuilder(100); // case should be sensitive //sb.append("(?i)"); newUri.setQuery(null); sb.append(newUri.toString().replaceAll("\\.", "\\.")); if (query != null) { String queryPattern = "(\\?" + query + ")?"; sb.append(queryPattern); } return sb.toString(); }
private static String getParams(Session session, URI uri, String postData) throws URIException { String leafName = ""; String query = ""; try { query = uri.getQuery(); } catch (URIException e) { log.error(e.getMessage(), e); } if (query == null) { query = ""; } leafName = leafName + getQueryParamString(session.getUrlParams(uri)); // also handle POST method query in body query = ""; if (postData != null && postData.length() > 0) { if (postData.equals("multipart/form-data")) { leafName = leafName + "(multipart/form-data)"; } else { leafName = leafName + getQueryParamString(session.getFormParams(uri, postData)); } } return leafName; } private static String getQueryParamString(Map<String, String> map) {
/** * Execute method, redirect once if returned status is redirect. * * @param httpClient http client * @param method http method * @return status * @throws IOException on error */ protected static int executeMethodFollowRedirectOnce(HttpClient httpClient, HttpMethod method) throws IOException { int status = httpClient.executeMethod(method); // need to follow redirects (once) on public folders if (isRedirect(status)) { method.releaseConnection(); URI targetUri = new URI(method.getResponseHeader("Location").getValue(), true); checkExpiredSession(targetUri.getQuery()); method.setURI(targetUri); status = httpClient.executeMethod(method); } return status; }
String query = newURI.getQuery(); if (query != null) { newURI.setQuery(null);
@SuppressWarnings("deprecation") public void setURI(org.apache.commons.httpclient.HttpMethodBase m, URI uri) throws URIException { HostConfiguration conf = m.getHostConfiguration(); if (uri.isAbsoluteURI()) { conf.setHost(new HttpHost(uri)); m.setHostConfiguration(conf); } m.setPath(uri.getPath() != null ? uri.getEscapedPath() : "/"); m.setQueryString(uri.getQuery()); }