This issue is based on #19, which targets the character encoding used during http authentication.
I expect the following change to be useless, because enc is the codepage independent base64 string. No need to require any special character set.
|
byte[] bytes = Base64.decodeBase64(enc.getBytes(basicParserCharset)); |
The actual question is the character encoding of the base64 decoded byte sequence stored in bytes. When storing this byte sequence as String (UTF-16), the platform's default charset matters:
|
String s = new String(bytes); |
I suggest implementing some simple encoding detection at this point and constructing the string platform independent similar to:
if(isUTF8(bytes)) {
s = new String(bytes, Charset.forName("UTF-8"));
}
else {
final String latin = new String(bytes, Charset.forName("ISO-8859-1"));
final byte[] lbytes = latin.getBytes(Charset.forName("UTF-8"));
s = new String(lbytes);
}
Actually, the list of expected charsets should be configurable.
This issue is based on #19, which targets the character encoding used during http authentication.
I expect the following change to be useless, because
encis the codepage independent base64 string. No need to require any special character set.milton2/milton-api/src/main/java/io/milton/http/Auth.java
Line 225 in 2feff46
The actual question is the character encoding of the base64 decoded byte sequence stored in
bytes. When storing this byte sequence as String (UTF-16), the platform's default charset matters:milton2/milton-api/src/main/java/io/milton/http/Auth.java
Line 226 in 2feff46
I suggest implementing some simple encoding detection at this point and constructing the string platform independent similar to:
Actually, the list of expected charsets should be configurable.