jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1511503 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java xdocs/changes.xml
Date Wed, 07 Aug 2013 21:25:45 GMT
Author: pmouawad
Date: Wed Aug  7 21:25:45 2013
New Revision: 1511503

URL: http://svn.apache.org/r1511503
Log:
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

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java?rev=1511503&r1=1511502&r2=1511503&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java
Wed Aug  7 21:25:45 2013
@@ -21,6 +21,8 @@ package org.apache.jmeter.protocol.http.
 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.c
 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);
     }
 

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java?rev=1511503&r1=1511502&r2=1511503&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java
Wed Aug  7 21:25:45 2013
@@ -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, 

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1511503&r1=1511502&r2=1511503&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Wed Aug  7 21:25:45 2013
@@ -224,6 +224,7 @@ Previously the default was 1, which coul
 <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>



Mime
View raw message