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

Side by Side Diff: runtime/vm/uri_test.cc

Issue 2035123002: Allow double-slash in uris. This is needed for data uri parsing. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/uri.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/uri.h" 5 #include "vm/uri.h"
6 #include "vm/unit_test.h" 6 #include "vm/unit_test.h"
7 7
8 namespace dart { 8 namespace dart {
9 9
10 TEST_CASE(ParseUri_WithScheme_NoQueryNoUser) { 10 TEST_CASE(ParseUri_WithScheme_NoQueryNoUser) {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 EXPECT(uri.scheme == NULL); 222 EXPECT(uri.scheme == NULL);
223 EXPECT(uri.userinfo == NULL); 223 EXPECT(uri.userinfo == NULL);
224 EXPECT(uri.host == NULL); 224 EXPECT(uri.host == NULL);
225 EXPECT(uri.port == NULL); 225 EXPECT(uri.port == NULL);
226 EXPECT_STREQ("", uri.path); 226 EXPECT_STREQ("", uri.path);
227 EXPECT(uri.query == NULL); 227 EXPECT(uri.query == NULL);
228 EXPECT_STREQ("fragment", uri.fragment); 228 EXPECT_STREQ("fragment", uri.fragment);
229 } 229 }
230 230
231 231
232 TEST_CASE(ParseUri_DoubleSlash1) {
233 ParsedUri uri;
234 EXPECT(!ParseUri("foo://example.com:8042/over//there?name=ferret", &uri));
235 EXPECT(uri.scheme == NULL);
236 EXPECT(uri.userinfo == NULL);
237 EXPECT(uri.host == NULL);
238 EXPECT(uri.port == NULL);
239 EXPECT(uri.path == NULL);
240 EXPECT(uri.query == NULL);
241 EXPECT(uri.fragment == NULL);
242 }
243
244
245 TEST_CASE(ParseUri_DoubleSlash2) {
246 ParsedUri uri;
247 EXPECT(!ParseUri("or//here", &uri));
248 EXPECT(uri.scheme == NULL);
249 EXPECT(uri.userinfo == NULL);
250 EXPECT(uri.host == NULL);
251 EXPECT(uri.port == NULL);
252 EXPECT(uri.path == NULL);
253 EXPECT(uri.query == NULL);
254 EXPECT(uri.fragment == NULL);
255 }
256
257
258 TEST_CASE(ParseUri_LowerCaseScheme) { 232 TEST_CASE(ParseUri_LowerCaseScheme) {
259 ParsedUri uri; 233 ParsedUri uri;
260 EXPECT(ParseUri("ScHeMe:path", &uri)); 234 EXPECT(ParseUri("ScHeMe:path", &uri));
261 EXPECT_STREQ("scheme", uri.scheme); 235 EXPECT_STREQ("scheme", uri.scheme);
262 EXPECT(uri.userinfo == NULL); 236 EXPECT(uri.userinfo == NULL);
263 EXPECT(uri.host == NULL); 237 EXPECT(uri.host == NULL);
264 EXPECT(uri.port == NULL); 238 EXPECT(uri.port == NULL);
265 EXPECT_STREQ("path", uri.path); 239 EXPECT_STREQ("path", uri.path);
266 EXPECT(uri.query == NULL); 240 EXPECT(uri.query == NULL);
267 EXPECT(uri.fragment == NULL); 241 EXPECT(uri.fragment == NULL);
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 const char* target_uri; 523 const char* target_uri;
550 EXPECT(ResolveUri("", 524 EXPECT(ResolveUri("",
551 "scheme:/%1g", 525 "scheme:/%1g",
552 &target_uri)); 526 &target_uri));
553 // We don't change broken escape sequences. 527 // We don't change broken escape sequences.
554 EXPECT_STREQ("scheme:/%1g", 528 EXPECT_STREQ("scheme:/%1g",
555 target_uri); 529 target_uri);
556 } 530 }
557 531
558 532
533 TEST_CASE(ResolveUri_DataUri) {
534 const char* data_uri =
535 "data:application/dart;charset=utf-8,%20%20%20%20%20%20%20%20import%20%22d art:isolate%22;%0A%0A%20%20%20%20%20%20%20%20import%20%22package:stream_channel/ stream_channel.dart%22;%0A%0A%20%20%20%20%20%20%20%20import%20%22package:test/sr c/runner/plugin/remote_platform_helpers.dart%22;%0A%20%20%20%20%20%20%20%20impor t%20%22package:test/src/runner/vm/catch_isolate_errors.dart%22;%0A%0A%20%20%20%2 0%20%20%20%20import%20%22file:///home/sra/xxxx/dev_compiler/test/all_tests.dart% 22%20as%20test;%0A%0A%20%20%20%20%20%20%20%20void%20main(_,%20SendPort%20message )%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20channel%20=%20serializeSuite(()%20 %7B%0A%20%20%20%20%20%20%20%20%20%20%20%20catchIsolateErrors();%0A%20%20%20%20%2 0%20%20%20%20%20%20%20return%20test.main;%0A%20%20%20%20%20%20%20%20%20%20%7D);% 0A%20%20%20%20%20%20%20%20%20%20new%20IsolateChannel.connectSend(message).pipe(c hannel);%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20"; // NOLINT
536
537 const char* target_uri;
538 EXPECT(ResolveUri(data_uri,
539 "bscheme://buser@bhost:11/base/path?baseQuery#bfragment",
540 &target_uri));
541 EXPECT_STREQ(data_uri, target_uri);
542 }
543
559 // dart:core Uri allows for the base url to be relative (no scheme, no 544 // dart:core Uri allows for the base url to be relative (no scheme, no
560 // authory, relative path) but this behavior is not in RFC 3986. We 545 // authory, relative path) but this behavior is not in RFC 3986. We
561 // do not implement this. 546 // do not implement this.
562 TEST_CASE(ResolveUri_RelativeBase_NotImplemented) { 547 TEST_CASE(ResolveUri_RelativeBase_NotImplemented) {
563 const char* target_uri; 548 const char* target_uri;
564 EXPECT(!ResolveUri("../r1", "b1/b2", &target_uri)); 549 EXPECT(!ResolveUri("../r1", "b1/b2", &target_uri));
565 EXPECT(target_uri == NULL); 550 EXPECT(target_uri == NULL);
566 551
567 EXPECT(!ResolveUri("..", "b1/b2", &target_uri)); 552 EXPECT(!ResolveUri("..", "b1/b2", &target_uri));
568 EXPECT(target_uri == NULL); 553 EXPECT(target_uri == NULL);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "./a/b/c/d/../../e")); 657 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "./a/b/c/d/../../e"));
673 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "../a/b/./c/d/../../e")); 658 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "../a/b/./c/d/../../e"));
674 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "./a/b/./c/d/../../e")); 659 EXPECT_STREQ(LH "/a/b/e", TestResolve(base, "./a/b/./c/d/../../e"));
675 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/.")); 660 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/."));
676 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/./.")); 661 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/./."));
677 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/././.")); 662 EXPECT_STREQ(LH "/a/b/e/", TestResolve(base, "./a/b/./c/d/../../e/././."));
678 #undef LH 663 #undef LH
679 } 664 }
680 665
681 } // namespace dart 666 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/uri.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698