mirror of https://github.com/apache/jmeter.git
Bug 54142 - HTTP Proxy Server throws an exception when path contains "|" character
Integrated my patch with a slight change to make current behaviour with Java Impl remain the same as bug only affects HC impls Bugzilla Id: 54142 git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1511503 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8075cd9049
commit
da3fc037c7
|
|
@ -21,6 +21,8 @@ package org.apache.jmeter.protocol.http.proxy;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -32,6 +34,8 @@ import org.apache.jmeter.protocol.http.control.Header;
|
|||
import org.apache.jmeter.protocol.http.control.HeaderManager;
|
||||
import org.apache.jmeter.protocol.http.gui.HeaderPanel;
|
||||
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
|
||||
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerFactory;
|
||||
import org.apache.jmeter.protocol.http.util.ConversionUtils;
|
||||
import org.apache.jmeter.protocol.http.util.HTTPConstants;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jmeter.util.JMeterUtils;
|
||||
|
|
@ -167,6 +171,29 @@ public class HttpRequestHdr {
|
|||
if (url.startsWith("/")) {
|
||||
url = HTTPS + "://" + paramHttps + url; // $NON-NLS-1$
|
||||
}
|
||||
// JAVA Impl accepts URLs with unsafe characters so don't do anything
|
||||
if(HTTPSamplerFactory.IMPL_JAVA.equals(httpSamplerName)) {
|
||||
log.debug("First Line: " + url);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// See Bug 54482
|
||||
URI testCleanUri = new URI(url);
|
||||
if(log.isDebugEnabled()) {
|
||||
log.debug("Successfully built URI from url:"+url);
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
log.warn("Url '" + url + "' contains unsafe characters, will escape it, message:"+e.getMessage());
|
||||
try {
|
||||
String escapedUrl = ConversionUtils.escapeIllegalURLCharacters(url);
|
||||
if(log.isDebugEnabled()) {
|
||||
log.debug("Successfully escaped url:'"+url +"' to:'"+escapedUrl+"'");
|
||||
}
|
||||
url = escapedUrl;
|
||||
} catch (Exception e1) {
|
||||
log.error("Error escaping URL:'"+url+"', message:"+e1.getMessage());
|
||||
}
|
||||
}
|
||||
log.debug("First Line: " + url);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,18 @@ public class ConversionUtils {
|
|||
return initial;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param url String Url to escape
|
||||
* @return String cleaned up url
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String escapeIllegalURLCharacters(String url) throws Exception{
|
||||
String decodeUrl = URLDecoder.decode(url,"UTF-8");
|
||||
URL urlString = new URL(decodeUrl);
|
||||
URI uri = new URI(urlString.getProtocol(), urlString.getUserInfo(), urlString.getHost(), urlString.getPort(), urlString.getPath(), urlString.getQuery(), urlString.getRef());
|
||||
return uri.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes reserved chars in a non-encoded URL.
|
||||
* Warning: if the input URL has already been (partially) encoded,
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@ Previously the default was 1, which could cause unexpected additional traffic.
|
|||
<li><bugzilla>55092</bugzilla> - Log message "WARN - jmeter.protocol.http.sampler.HTTPSamplerBase: Null URL detected (should not happen)" displayed when embedded resource URL is malformed</li>
|
||||
<li><bugzilla>55161</bugzilla> - Useless processing in SoapSampler.setPostHeaders</li>
|
||||
<li><bugzilla>54482</bugzilla> - HC fails to follow redirects with non-encoded chars</li>
|
||||
<li><bugzilla>54142</bugzilla> - HTTP Proxy Server throws an exception when path contains "|" character</li>
|
||||
</ul>
|
||||
|
||||
<h3>Other Samplers</h3>
|
||||
|
|
|
|||
Loading…
Reference in New Issue