try { if(redirectUri.hasQuery()) { redirectUri.setQuery(null);
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(); }
@Override public String setParameter(HttpMessage msg, NameValuePair originalPair, String param, String value) { // TODO: Implement correctly escaped / non-escaped params OperationParameter opParam = mapParameters.get(param); if (opParam != null) { String newfilter = opParam.getModifiedFilter(value); String modifiedQuery = beforeFilterExpression + newfilter + afterFilterExpression; try { msg.getRequestHeader().getURI().setQuery(modifiedQuery); } catch (URIException | NullPointerException e) { log.error("Exception with the modified query " + modifiedQuery, e); } return newfilter; } return null; }
public synchronized void add(URI uri, String key, Object value) { // ZAP: catch CloneNotSupportedException as introduced with version 3.1 of HttpClient try { uri = (URI) uri.clone(); } catch (CloneNotSupportedException e1) { return; } // ZAP: Removed variable (TreeMap map). try { uri.setQuery(null); } catch (URIException e) { // ZAP: Added logging. logger.error(e.getMessage(), e); return; } // ZAP: Moved to after the try catch block. String uriKey = uri.toString(); // ZAP: Added the type arguments. TreeMap<String, Object> map = mapURI.get(uriKey); if (map == null) { // ZAP: Added the type argument. map = new TreeMap<>(); mapURI.put(uriKey, map); } // ZAP: Removed else branch. add(map, key, value); }
protected String getScriptBasedFormURL(HttpMethod initmethod, String pathQuery) throws URIException { URI initmethodURI = initmethod.getURI(); int queryIndex = pathQuery.indexOf('?'); if (queryIndex >= 0) { if (queryIndex > 0) { // update path String newPath = pathQuery.substring(0, queryIndex); if (newPath.startsWith("/")) { // absolute path initmethodURI.setPath(newPath); } else { String currentPath = initmethodURI.getPath(); int folderIndex = currentPath.lastIndexOf('/'); if (folderIndex >= 0) { // replace relative path initmethodURI.setPath(currentPath.substring(0, folderIndex + 1) + newPath); } else { // should not happen initmethodURI.setPath('/' + newPath); } } } initmethodURI.setQuery(pathQuery.substring(queryIndex + 1)); } return initmethodURI.getURI(); }
public synchronized Vector<Object> getList(URI uri, String key) { // ZAP: catch CloneNotSupportedException as introduced with version 3.1 of HttpClient try { uri = (URI) uri.clone(); } catch (CloneNotSupportedException e1) { return null; } // ZAP: Removed variable (TreeMap map). try { uri.setQuery(null); } catch (URIException e) { // ZAP: Added logging. logger.error(e.getMessage(), e); return null; } // ZAP: Moved to after the try catch block. String uriKey = uri.toString(); // ZAP: Added the type argument and removed the instanceof. TreeMap<String, Object> map = mapURI.get(uriKey); if (map == null) { return null; } // ZAP: Removed else branch. return getList(map, key); }
protected String getAbsoluteUri(HttpMethod method, String path) throws URIException { URI uri = method.getURI(); if (path != null) { // reset query string uri.setQuery(null); if (path.startsWith("/")) { // path is absolute, replace method path uri.setPath(path); } else if (path.startsWith("http://") || path.startsWith("https://")) { return path; } else { // relative path, build new path String currentPath = method.getPath(); int end = currentPath.lastIndexOf('/'); if (end >= 0) { uri.setPath(currentPath.substring(0, end + 1) + path); } else { throw new URIException(uri.getURI()); } } } return uri.getURI(); }
@Override public void onHttpRequestSend(HttpMessage msg) { HttpRequestHeader header = msg.getRequestHeader(); if (header != null ) { String cookie = header.getHeader("Cookie"); synchronized (cookieList){ if (cookie != null && cookieList.indexOf(cookie)==-1){ try { // ZAP: catch CloneNotSupportedException as introduced with version 3.1 of HttpClient URI uri; try { uri = (URI) header.getURI().clone(); } catch (CloneNotSupportedException e) { throw new URIException(e.getMessage()); } uri.setQuery(null); String sUri = uri.toString(); cookieList.add(cookie); getView().getOutputPanel().append(sUri + DELIM + cookie + "\n"); } catch (URIException e) { // ZAP: Print stack trace to Output tab getView().getOutputPanel().append(e); } } } } }
String query = newURI.getQuery(); if (query != null) { newURI.setQuery(null); firstline = newURI.toString();
String query = httpMessage.getRequestBody().toString(); if (query != null) { newURI.setQuery(null); firstline = newURI.toString();
try { if(redirectUri.hasQuery()) { redirectUri.setQuery(null);
try { if(redirectUri.hasQuery()) { redirectUri.setQuery(null);
try { if(redirectUri.hasQuery()) { redirectUri.setQuery(null);
try { if(redirectUri.hasQuery()) { redirectUri.setQuery(null);
try { if(redirectUri.hasQuery()) { redirectUri.setQuery(null);
uri.setQuery(null); String path = uri.getPath(); path = path.replaceAll("/[^/]*$", "");
URI baseUri = (URI) baseMsg.getRequestHeader().getURI().clone(); baseUri.setQuery(null);