-
Notifications
You must be signed in to change notification settings - Fork 126
Open
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels