|
|
@@ -99,13 +99,11 @@ public class CDataHandler implements URIHandler {
|
|
|
*/
|
|
|
private class CDataHandle extends CHandle {
|
|
|
|
|
|
- public final URI uri;
|
|
|
- public final String mime;
|
|
|
- public final boolean isText;
|
|
|
- public final boolean isBase64;
|
|
|
- public final Charset charset;
|
|
|
- public final byte[] data;
|
|
|
- public final String text;
|
|
|
+ private final URI uri;
|
|
|
+ private final MaskSet<URIFlags> flags;
|
|
|
+ private final Charset charset;
|
|
|
+ private final byte[] data;
|
|
|
+ private final String text;
|
|
|
|
|
|
public CDataHandle(URI uri) throws IOException {
|
|
|
Matcher hit = RE_DATA_SCHEME.matcher(uri.getRawSchemeSpecificPart());
|
|
|
@@ -113,20 +111,19 @@ public class CDataHandler implements URIHandler {
|
|
|
throw new IOException("Invalid data URI: " + uri);
|
|
|
}
|
|
|
|
|
|
+ boolean isBase64 = hit.group(3) != null;
|
|
|
+ String mime = ValueUtils.or(hit.group(1), "text/plain");
|
|
|
+
|
|
|
this.uri = uri;
|
|
|
- this.mime = ValueUtils.or(hit.group(1), "text/plain");
|
|
|
this.charset = getCharset(hit.group(2));
|
|
|
- this.isText = mime.startsWith("text/");
|
|
|
- this.isBase64 = hit.group(3) != null;
|
|
|
-
|
|
|
- String body = hit.group(4);
|
|
|
+ this.flags = mime.startsWith("text/") ? TXT_FLAGS : BIN_FLAGS;
|
|
|
|
|
|
- if(!isBase64) {
|
|
|
- text = URLDecoder.decode(body, charset.name());
|
|
|
- data = text.getBytes(charset);
|
|
|
- } else {
|
|
|
- data = Base64.getDecoder().decode(body);
|
|
|
+ if (isBase64) {
|
|
|
+ data = Base64.getDecoder().decode(hit.group(4));
|
|
|
text = new String(data, charset);
|
|
|
+ } else {
|
|
|
+ text = URLDecoder.decode(hit.group(4), charset.name());
|
|
|
+ data = text.getBytes(charset);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -166,7 +163,7 @@ public class CDataHandler implements URIHandler {
|
|
|
|
|
|
@Override
|
|
|
public Set<URIFlags> flags() {
|
|
|
- return isText ? TXT_FLAGS : BIN_FLAGS;
|
|
|
+ return flags;
|
|
|
}
|
|
|
|
|
|
@Override
|