KEYCLOAK-18289: use utf-8 encoding for simplehttp (#8025)
Co-authored-by: Stian Thorgersen <stianst@gmail.com>
This commit is contained in:
parent
f145667144
commit
343d181a4e
2 changed files with 9 additions and 1 deletions
|
@ -314,7 +314,7 @@ public class SimpleHttp {
|
|||
}
|
||||
}
|
||||
|
||||
return new UrlEncodedFormEntity(urlParameters);
|
||||
return new UrlEncodedFormEntity(urlParameters, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public static class Response {
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.junit.runners.Parameterized.Parameters;
|
|||
import org.keycloak.common.util.StreamUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
@ -99,6 +100,13 @@ public final class SimpleHttpTest {
|
|||
assertEquals("{\"value\":\"" + value + "\"}", client.data);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requestWithEncodingParam() throws IOException {
|
||||
HttpClientMock client = new HttpClientMock();
|
||||
SimpleHttp.doPost("", client).param("dummy", value).asResponse();
|
||||
assertEquals("dummy=" + URLEncoder.encode(value, "UTF-8"), client.data);
|
||||
}
|
||||
|
||||
public static final class DummyEntity {
|
||||
public String value;
|
||||
public DummyEntity(String value) {
|
||||
|
|
Loading…
Reference in a new issue