mirror of
https://github.com/kuroppoi/entralinked.git
synced 2026-09-12 02:35:15 -05:00
Don't URL decode/encode values if base64 decoding/encoding is enabled
This commit is contained in:
@@ -98,15 +98,14 @@ public class UrlEncodedFormGenerator extends SimpleGeneratorBase {
|
||||
writer.write('=');
|
||||
}
|
||||
|
||||
String value = text;
|
||||
|
||||
// Encode value as base64 if feature is enabled
|
||||
// Otherwise, encode using URLEncoder.
|
||||
if(Feature.BASE64_ENCODE_VALUES.enabledIn(formatFeatures)) {
|
||||
value = Base64.getEncoder().encodeToString(text.getBytes(StandardCharsets.ISO_8859_1))
|
||||
.replace('=', '*').replace('+', '.').replace('/', '-');
|
||||
writer.write(Base64.getEncoder().encodeToString(text.getBytes(StandardCharsets.ISO_8859_1))
|
||||
.replace('=', '*').replace('+', '.').replace('/', '-'));
|
||||
} else {
|
||||
writer.write(URLEncoder.encode(text, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
writer.write(URLEncoder.encode(value, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -101,13 +101,14 @@ public class UrlEncodedFormParser extends SimpleParserBase {
|
||||
_currToken = JsonToken.VALUE_STRING;
|
||||
|
||||
// Decode base64 if feature is enabled
|
||||
// Otherwise, decode using URLDecoder.
|
||||
if(Feature.BASE64_DECODE_VALUES.enabledIn(formatFeatures)) {
|
||||
parsedString = new String(Base64.getDecoder().decode(
|
||||
parsedString.replace('*', '=').replace('.', '+').replace('-', '/')), StandardCharsets.ISO_8859_1);
|
||||
context.setCurrentValue(new String(Base64.getDecoder().decode(
|
||||
parsedString.replace('*', '=').replace('.', '+').replace('-', '/')), StandardCharsets.ISO_8859_1));
|
||||
} else {
|
||||
context.setCurrentValue(URLDecoder.decode(parsedString, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
context.setCurrentValue(URLDecoder.decode(parsedString, StandardCharsets.UTF_8));
|
||||
|
||||
if(i != '&') {
|
||||
if(i != -1) {
|
||||
_reportUnexpectedChar(i, "expected '&' to mark end of value and start of new key");
|
||||
|
||||
Reference in New Issue
Block a user