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

Unified Diff: tests/corelib/uri_test.dart

Issue 2626013004: Fix invalid URIs generated using Uri constructor with clever paths. (Closed)
Patch Set: Created 3 years, 11 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
« sdk/lib/core/uri.dart ('K') | « sdk/lib/core/uri.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/uri_test.dart
diff --git a/tests/corelib/uri_test.dart b/tests/corelib/uri_test.dart
index 9e4b24f0d61eb96565ba3f72037dbaf9ace985c0..d4ca36dd9afe8920ef9752c48f57483561068733 100644
--- a/tests/corelib/uri_test.dart
+++ b/tests/corelib/uri_test.dart
@@ -755,6 +755,25 @@ void testReplace() {
Expect.equals("s://:1/b/c?d#e", uri.replace(host: "").toString());
}
+void testRegression28359() {
+ var uri = new Uri(path: "//");
+ // This is an invalid path for a URI reference with no authority
+ // since it looks like an authority.
+ // Normalized to have an authority.
+ Expect.equals("////", "$uri");
+ Expect.equals("//", uri.path);
+ Expect.isTrue(uri.hasAuthority, "$uri has authority");
+
+ uri = new Uri(path: "file:///wat");
+ // This is an invalid pat for a URI reference with no authority or scheme
floitsch 2017/01/12 16:05:49 path
Lasse Reichstein Nielsen 2017/01/16 08:17:23 Done.
+ // since the path looks like it starts with a scheme.
+ // Normalized by escaping the ":".
+ Expect.equals("file%3A///wat", uri.path);
+ Expect.equals("file%3A///wat", "$uri");
+ Expect.isFalse(uri.hasAuthority);
+ Expect.isFalse(uri.hasScheme);
+}
+
main() {
testUri("http:", true);
testUri("file:///", true);
@@ -921,6 +940,7 @@ main() {
testInvalidUrls();
testNormalization();
testReplace();
+ testRegression28359();
}
String dump(Uri uri) {
« sdk/lib/core/uri.dart ('K') | « sdk/lib/core/uri.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698