KEYCLOAK-18289: use utf-8 encoding for simplehttp (#8025)

Co-authored-by: Stian Thorgersen <stianst@gmail.com>
This commit is contained in:
Bastian 2022-08-25 13:02:41 +02:00 committed by GitHub
parent f145667144
commit 343d181a4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -314,7 +314,7 @@ public class SimpleHttp {
}
}
return new UrlEncodedFormEntity(urlParameters);
return new UrlEncodedFormEntity(urlParameters, StandardCharsets.UTF_8);
}
public static class Response {

View file

@ -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) {