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

Unified Diff: sdk/lib/core/uri.dart

Issue 1994623002: Make Uri.parse("data:...") go through UriData.parse. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/uri.dart
diff --git a/sdk/lib/core/uri.dart b/sdk/lib/core/uri.dart
index 1d351068115f9ab3c38c1c7d05fd00dd3cd2563d..5718ca80b83b870dd578011592707b4c7d99cdc4 100644
--- a/sdk/lib/core/uri.dart
+++ b/sdk/lib/core/uri.dart
@@ -500,6 +500,12 @@ class Uri {
if (i == start) _fail(uri, start, "Invalid empty scheme");
scheme = _makeScheme(uri, start, i);
i++;
+ if (scheme == "data") {
+ // This generates a URI that is (potentially) not path normalized.
+ // Applying part normalization to a non-hierarchial URI isn't
+ // meaningful.
+ return UriData._parse(uri, i, null).uri;
+ }
pathStart = i;
if (i == end) {
char = EOI;
@@ -3040,9 +3046,10 @@ class UriData {
end = queryIndex;
}
path = _text.substring(colonIndex + 1, end);
- // TODO(lrn): This is probably too simple. We should ensure URI
- // normalization before passing in the raw strings, maybe using
- // Uri._makePath, Uri._makeQuery.
+ // TODO(lrn): This can generate a URI that isn't path normalized.
+ // That's perfectly reasonable - data URIs are not hierarchical,
+ // but it may make some consumers stumble.
+ // Should we at least do escape normalization?
_uriCache = new Uri._internal("data", "", null, null, path, query, null);
return _uriCache;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698