You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2013/11/23 14:08:29 UTC

svn commit: r1544786 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java xdocs/changes.xml

Author: sebb
Date: Sat Nov 23 13:08:28 2013
New Revision: 1544786

URL: http://svn.apache.org/r1544786
Log:
Proxy#getDomainMatch does not handle wildcards correctly
Bugzilla Id: 55815

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

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java?rev=1544786&r1=1544785&r2=1544786&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java Sat Nov 23 13:08:28 2013
@@ -362,8 +362,10 @@ public class Proxy extends Thread {
      * Get matching alias for a host from keyStore that may contain domain aliases.
      * Assumes domains must have at least 2 parts (apache.org);
      * does not check if TLD requires more (google.co.uk).
-     * ProxyControl checks for valid domains before adding them, and any subsequent
-     * additions by the Proxy class will be hosts, not domains.
+     * Note that DNS wildcards only apply to a single level, i.e.
+     * podling.incubator.apache.org matches *.incubator.apache.org
+     * but does not match *.apache.org
+     *
      * @param keyStore the KeyStore to search
      * @param host the hostname to match
      * @return the keystore entry or {@code null} if no match found
@@ -375,17 +377,15 @@ public class Proxy extends Thread {
         }
         String parts[] = host.split("\\."); // get the component parts
         // Assume domains must have at least 2 parts, e.g. apache.org
-        // Don't try matching against *.org; however we don't check *.co.uk here
-        for(int i = 1; i <= parts.length - 2; i++) {
-            StringBuilder sb = new StringBuilder("*");
-            for(int j = i; j < parts.length ; j++) { // add the remaining parts
-                sb.append('.');
-                sb.append(parts[j]);
-            }
-            String alias = sb.toString();
-            if (keyStore.containsAlias(alias)) {
-                return alias;
-            }
+        // Replace the first part with "*" 
+        StringBuilder sb = new StringBuilder("*"); // $NON-NLS-1$
+        for(int j = 1; j < parts.length ; j++) { // Skip the first part
+            sb.append('.');
+            sb.append(parts[j]);
+        }
+        String alias = sb.toString();
+        if (keyStore.containsAlias(alias)) {
+            return alias;
         }
         return null;
     }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1544786&r1=1544785&r2=1544786&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sat Nov 23 13:08:28 2013
@@ -126,9 +126,10 @@ A workaround is to use a Java 7 update 4
 
 <ch_section>Bug fixes</ch_section>
 
-<h3>HTTP Samplers and Proxy</h3>
+<h3>HTTP Samplers and Test Script Recorder</h3>
 <ul>
-<li><bugzilla>55717</bugzilla> - Bad handling of Redirect when URLs are in relative format by HttpClient4 and HttpClient31</li>
+<li><bugzilla>55815</bugzilla> - Proxy#getDomainMatch does not handle wildcards correctly</li>
+<li><bugzilla>55717</bugzilla> - Bad handling of Redirect when URLs are in relative format by HttpClient4 and HttpClient3.1</li>
 </ul>
 
 <h3>Other Samplers</h3>