jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1548710 - in /jmeter/trunk: src/core/org/apache/jmeter/samplers/SampleResult.java src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java xdocs/changes.xml
Date Fri, 06 Dec 2013 20:03:21 GMT
Author: pmouawad
Date: Fri Dec  6 20:03:20 2013
New Revision: 1548710

URL: http://svn.apache.org/r1548710
Log:
Bug 55852 - Be more lenient in parsing when charset value is surrounded with single quotes
Bugzilla Id: 55852

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java?rev=1548710&r1=1548709&r2=1548710&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java Fri Dec  6 20:03:20
2013
@@ -755,7 +755,7 @@ public class SampleResult implements Ser
                     charSet=charSet.substring(0, semiColon);
                 }
                 // Check for quoted string
-                if (charSet.startsWith("\"")){ // $NON-NLS-1$
+                if (charSet.startsWith("\"")||charSet.startsWith("\'")){ // $NON-NLS-1$
                     setDataEncoding(charSet.substring(1, charSet.length()-1)); // remove
quotes
                 } else {
                     setDataEncoding(charSet);

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=1548710&r1=1548709&r2=1548710&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 Fri Dec
 6 20:03:20 2013
@@ -28,6 +28,7 @@ import java.io.PrintStream;
 import java.net.Socket;
 import java.net.URL;
 import java.net.UnknownHostException;
+import java.nio.charset.IllegalCharsetNameException;
 import java.security.GeneralSecurityException;
 import java.security.KeyStore;
 import java.security.KeyStoreException;
@@ -566,7 +567,12 @@ public class Proxy extends Thread {
      * @return the page encoding found for the sample result, or null
      */
     private String addPageEncoding(SampleResult result) {
-        String pageEncoding = ConversionUtils.getEncodingFromContentType(result.getContentType());
+        String pageEncoding = null;
+        try {
+            pageEncoding = ConversionUtils.getEncodingFromContentType(result.getContentType());
+        } catch(IllegalCharsetNameException ex) {
+            log.warn("Unsupported charset detected in contentType:'"+result.getContentType()+"',
will continue processing with default charset", ex);
+        }
         if(pageEncoding != null) {
             String urlWithoutQuery = getUrlWithoutQuery(result.getURL());
             synchronized(pageEncodings) {

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=1548710&r1=1548709&r2=1548710&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
Fri Dec  6 20:03:20 2013
@@ -25,14 +25,15 @@ import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLDecoder;
 import java.nio.charset.Charset;
+import java.nio.charset.IllegalCharsetNameException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.http.client.utils.URIBuilder;
-import org.apache.jorphan.util.JOrphanUtils;
 
 // @see TestHTTPUtils for unit tests
 
@@ -56,6 +57,7 @@ public class ConversionUtils {
      *
      * @param contentType
      * @return the charset encoding - or null, if none was found or the charset is not supported
+     * @throws IllegalCharsetNameException 
      */
     public static String getEncodingFromContentType(String contentType){
         String charSet = null;
@@ -64,8 +66,8 @@ public class ConversionUtils {
             if (charSetStartPos >= 0) {
                 charSet = contentType.substring(charSetStartPos + CHARSET_EQ_LEN);
                 if (charSet != null) {
-                    // Remove quotes from charset name
-                    charSet = JOrphanUtils.replaceAllChars(charSet, '"', "");
+                    // Remove quotes from charset name, see bug 55852
+                    charSet = StringUtils.replaceChars(charSet, "\'\"", null);
                     charSet = charSet.trim();
                     if (charSet.length() > 0) {
                         // See Bug 44784
@@ -88,6 +90,11 @@ public class ConversionUtils {
         return charSet;
     }
 
+    public static void main(String[] args) {
+        //System.out.println(getEncodingFromContentType("charset='UTF-8'"));
+        
+        System.out.println(StringUtils.replaceChars("a'b'c\"cece\'zadad\"", "\'\"", null));
+    }
     /**
      * Generate a relative URL, allowing for extraneous leading "../" segments.
      * The Java {@link URL#URL(URL, String)} constructor does not remove these.

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1548710&r1=1548709&r2=1548710&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Fri Dec  6 20:03:20 2013
@@ -205,6 +205,7 @@ A workaround is to use a Java 7 update 4
 <li><bugzilla>55693</bugzilla> - Add a "Save as Test Fragment" option</li>
 <li><bugzilla>55753</bugzilla> - Improve FilePanel behaviour to start from
the value set in Filename field if any. Contributed by UBIK Load Pack (support at ubikloadpack.com)</li>
 <li><bugzilla>55756</bugzilla> - HTTP Mirror Server : Add ability to set
Headers</li>
+<li><bugzilla>55852</bugzilla> - Be more lenient in parsing when charset
value is surrounded with single quotes</li>
 </ul>
 
 <ch_section>Non-functional changes</ch_section>



Mime
View raw message