Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Unified Diff: runtime/bin/vmservice/loader.dart

Issue 1489603002: Standalone: Use new support in dart:core for decoding data uris. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/tests/vm/vm.status » ('j') | runtime/tests/vm/vm.status » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmservice/loader.dart
diff --git a/runtime/bin/vmservice/loader.dart b/runtime/bin/vmservice/loader.dart
index cd94f579ba0f39619f5de516dcb1b941d13a3d37..38b62b171a8c1dd40090bc174040ec5dad4c045a 100644
--- a/runtime/bin/vmservice/loader.dart
+++ b/runtime/bin/vmservice/loader.dart
@@ -62,32 +62,16 @@ void _loadFile(SendPort sp, int id, Uri uri) {
});
}
-var dataUriRegex = new RegExp(
- r"data:([\w-]+/[\w-]+)?(;charset=([\w-]+))?(;base64)?,(.*)");
-
void _loadDataUri(SendPort sp, int id, Uri uri) {
try {
- var match = dataUriRegex.firstMatch(uri.toString());
- if (match == null) throw "Malformed data uri";
-
- var mimeType = match.group(1);
- var encoding = match.group(3);
- var maybeBase64 = match.group(4);
- var encodedData = match.group(5);
-
- if (mimeType != "application/dart") {
+ if (uri.data.mimeType != "application/dart") {
throw "MIME-type must be application/dart";
}
- if (encoding != "utf-8") {
- // Default is ASCII. The C++ portion of the embedder assumes UTF-8.
+ if (uri.data.charset != "utf-8") {
+ // The C++ portion of the embedder assumes UTF-8.
throw "Only utf-8 encoding is supported";
}
- if (maybeBase64 != null) {
- throw "Only percent encoding is supported";
- }
-
- var data = UTF8.encode(Uri.decodeComponent(encodedData));
- _sendResourceResponse(sp, id, data);
+ _sendResourceResponse(sp, id, uri.data.contentAsBytes());
} catch (e) {
_sendResourceResponse(sp, id, "Invalid data uri ($uri):\n $e");
}
« no previous file with comments | « no previous file | runtime/tests/vm/vm.status » ('j') | runtime/tests/vm/vm.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698