Skip to content

Query string: & character in double quotes is not encoded properly #180

@erichirlemann

Description

@erichirlemann

When query string parameter value an ampersand inside a double-quote, leading the string after & being misinterpreted as the next parameter.

Reproducer:

package com.hirle;

import java.net.MalformedURLException;
import java.net.URL;
import com.github.kevinsawicki.http.HttpRequest;


public class Reproducer 
{
    public static void main( String[] args )
    {
        URL webHookUrl = getWebHookURL();

        HttpRequest httpRequest = HttpRequest
          .get(webHookUrl.toExternalForm(), true, "movie", "Named \"Bonnie&Clyde\"")
          .acceptJson();
        int returnedCode = httpRequest.code();
        System.out.println("Returned code: " + returnedCode);
    }

    private static URL getWebHookURL() {
    try {
      return new URL("https://webhook.site/PUT_YOUR_WEBHOOK_HERE");
    } catch (MalformedURLException exception) {
      throw new IllegalStateException(exception);
    }
  }
}

Expected: GET https://webhook.site/c0c8cb19-e679-4036-94ac-5fdaea3463fa?movie=Named%20%22Bonnie%26Clyde%22
Obtained: GET https://webhook.site/c0c8cb19-e679-4036-94ac-5fdaea3463fa?movie=Named%20%22Bonnie&Clyde%22

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions