From cdd76a58d640a8139aa6df8f2a127301bf183023 Mon Sep 17 00:00:00 2001 From: offa Date: Fri, 6 Jan 2023 19:12:20 +0000 Subject: [PATCH] Use encoding of the request (#174) * Use encoding of the request * Fall back to UTF-8 if the request has no encoding specified --- src/main/java/hudson/security/LDAPSecurityRealm.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/hudson/security/LDAPSecurityRealm.java b/src/main/java/hudson/security/LDAPSecurityRealm.java index ef01aa6b..b1f532ef 100644 --- a/src/main/java/hudson/security/LDAPSecurityRealm.java +++ b/src/main/java/hudson/security/LDAPSecurityRealm.java @@ -96,6 +96,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -1535,7 +1536,7 @@ public FormValidation doValidate(StaplerRequest req) throws Exception { return FormValidation.ok(); } // extract the submitted details - JSONObject json = JSONObject.fromObject(IOUtils.toString(req.getInputStream(), Charset.defaultCharset())); + JSONObject json = JSONObject.fromObject(IOUtils.toString(req.getInputStream(), Util.fixNull(req.getCharacterEncoding(), StandardCharsets.UTF_8.name()))); String user = json.getString("testUser"); String password = json.getString("testPassword"); JSONObject realmCfg;