jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1511488 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java
Date Wed, 07 Aug 2013 23:00:13 GMT
On 7 August 2013 22:05,  <pmouawad@apache.org> wrote:
> Author: pmouawad
> Date: Wed Aug  7 21:05:29 2013
> New Revision: 1511488
>
> URL: http://svn.apache.org/r1511488
> Log:
> Bug 54482 - HC fails to follow redirects with non-encoded chars
> Fix as per sebb comment
> Bugzilla Id: 54482
>
> Modified:
>     jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java
>
> 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=1511488&r1=1511487&r2=1511488&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:05:29 2013
> @@ -18,10 +18,12 @@
>
>  package org.apache.jmeter.protocol.http.util;
>
> +import java.io.UnsupportedEncodingException;
>  import java.net.MalformedURLException;
>  import java.net.URI;
>  import java.net.URISyntaxException;
>  import java.net.URL;
> +import java.net.URLDecoder;
>  import java.nio.charset.Charset;
>  import java.util.ArrayList;
>  import java.util.List;
> @@ -123,15 +125,16 @@ public class ConversionUtils {
>       * @param url non-encoded URL
>       * @return URI which has been encoded as necessary
>       * @throws URISyntaxException
> +     * @throws UnsupportedEncodingException
>       */
> -    public static final URI sanitizeUrl(URL url) throws URISyntaxException {
> +    public static final URI sanitizeUrl(URL url) throws URISyntaxException, UnsupportedEncodingException
{
>          URIBuilder builder =
>                  new URIBuilder()
>              .setScheme(url.getProtocol())
>              .setHost(url.getHost())
>              .setPort(url.getPort())
>              .setUserInfo(url.getUserInfo())
> -            .setPath(url.getPath())
> +            .setPath(URLDecoder.decode(url.getPath(), "UTF-8")) // $NON-NLS-1$

This changes the behaviour of the method; the Javadoc needs adjusting.

The method now assumes that the input URL has been (partially)
encoded; it won't work on all unencoded URLs.

For example, the unencoded URL http://localhost/% will cause an Exception.
Any instances of % must have been encoded as %25 within the path portion.

Hopefully that assumption is valid for the use JMeter makes of the
method, but it needs to be documented.

>              .setQuery(url.getQuery());
>          URI uri = builder.build();
>          return uri;
>
>

Mime
View raw message