mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
#970 use iso-8859-1 for http post args instead of us-ascii
This commit is contained in:
@@ -119,14 +119,7 @@ public final class WireProtocol {
|
|||||||
if (request instanceof HgServletRequest) {
|
if (request instanceof HgServletRequest) {
|
||||||
HgServletRequest hgRequest = (HgServletRequest) request;
|
HgServletRequest hgRequest = (HgServletRequest) request;
|
||||||
|
|
||||||
try {
|
parseHttpPostArgs(listOfCmds, hgArgsPostSize, hgRequest);
|
||||||
byte[] bytes = hgRequest.getInputStream().readAndCapture(hgArgsPostSize);
|
|
||||||
String hgArgs = new String(bytes, Charsets.US_ASCII);
|
|
||||||
String decoded = decodeValue(hgArgs);
|
|
||||||
parseHgCommandHeader(listOfCmds, decoded);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
throw Throwables.propagate(ex);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("could not process the httppostargs protocol without HgServletRequest");
|
throw new IllegalArgumentException("could not process the httppostargs protocol without HgServletRequest");
|
||||||
}
|
}
|
||||||
@@ -134,6 +127,19 @@ public final class WireProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void parseHttpPostArgs(List<String> listOfCmds, int hgArgsPostSize, HgServletRequest hgRequest) {
|
||||||
|
try {
|
||||||
|
byte[] bytes = hgRequest.getInputStream().readAndCapture(hgArgsPostSize);
|
||||||
|
// we use iso-8859-1 for encoding, because the post args are normally http headers which are using iso-8859-1
|
||||||
|
// see https://tools.ietf.org/html/rfc7230#section-3.2.4
|
||||||
|
String hgArgs = new String(bytes, Charsets.ISO_8859_1);
|
||||||
|
String decoded = decodeValue(hgArgs);
|
||||||
|
parseHgCommandHeader(listOfCmds, decoded);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw Throwables.propagate(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void parseHgArgHeaders(HttpServletRequest request, List<String> listOfCmds) {
|
private static void parseHgArgHeaders(HttpServletRequest request, List<String> listOfCmds) {
|
||||||
Enumeration headerNames = request.getHeaderNames();
|
Enumeration headerNames = request.getHeaderNames();
|
||||||
while (headerNames.hasMoreElements()) {
|
while (headerNames.hasMoreElements()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user