Skip to content

Commit

Permalink
Use encoding of the request (#174)
Browse files Browse the repository at this point in the history
* Use encoding of the request

* Fall back to UTF-8 if the request has no encoding specified
  • Loading branch information
offa authored Jan 6, 2023
1 parent 481e42f commit cdd76a5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/hudson/security/LDAPSecurityRealm.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit cdd76a5

Please sign in to comment.