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

Side by Side Diff: sdk/lib/core/uri.dart

Issue 347393003: Fix bugs in Uri: Allow empty port, handle path starting with "//" in toString. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/corelib/uri_test.dart » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of dart.core; 5 part of dart.core;
6 6
7 /** 7 /**
8 * A parsed URI, such as a URL. 8 * A parsed URI, such as a URL.
9 * 9 *
10 * **See also:** 10 * **See also:**
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 index++; 227 index++;
228 char = EOI; 228 char = EOI;
229 } 229 }
230 int hostStart = authStart; 230 int hostStart = authStart;
231 int hostEnd = index; 231 int hostEnd = index;
232 if (lastAt >= 0) { 232 if (lastAt >= 0) {
233 userinfo = _makeUserInfo(uri, authStart, lastAt); 233 userinfo = _makeUserInfo(uri, authStart, lastAt);
234 hostStart = lastAt + 1; 234 hostStart = lastAt + 1;
235 } 235 }
236 if (lastColon >= 0) { 236 if (lastColon >= 0) {
237 if (lastColon + 1 == index) {
238 _fail(uri, index, "Invalid port number");
239 }
240 int portNumber = 0; 237 int portNumber = 0;
241 for (int i = lastColon + 1; i < index; i++) { 238 for (int i = lastColon + 1; i < index; i++) {
242 int digit = uri.codeUnitAt(i); 239 int digit = uri.codeUnitAt(i);
243 if (_ZERO > digit || _NINE < digit) { 240 if (_ZERO > digit || _NINE < digit) {
244 _fail(uri, i, "Invalid port number"); 241 _fail(uri, i, "Invalid port number");
245 } 242 }
246 portNumber = portNumber * 10 + (digit - _ZERO); 243 portNumber = portNumber * 10 + (digit - _ZERO);
247 } 244 }
248 port = _makePort(portNumber, scheme); 245 port = _makePort(portNumber, scheme);
249 hostEnd = lastColon; 246 hostEnd = lastColon;
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 ss.write(_host == null ? "null" : _host); 1475 ss.write(_host == null ? "null" : _host);
1479 if (_port != 0) { 1476 if (_port != 0) {
1480 ss.write(":"); 1477 ss.write(":");
1481 ss.write(_port.toString()); 1478 ss.write(_port.toString());
1482 } 1479 }
1483 } 1480 }
1484 1481
1485 String toString() { 1482 String toString() {
1486 StringBuffer sb = new StringBuffer(); 1483 StringBuffer sb = new StringBuffer();
1487 _addIfNonEmpty(sb, scheme, scheme, ':'); 1484 _addIfNonEmpty(sb, scheme, scheme, ':');
1488 if (hasAuthority || (scheme == "file")) { 1485 if (hasAuthority || path.startsWith("//") || (scheme == "file")) {
1486 // File URIS always have the authority, even if it is empty.
1487 // The empty URI means "localhost".
1489 sb.write("//"); 1488 sb.write("//");
1490 _writeAuthority(sb); 1489 _writeAuthority(sb);
1491 } 1490 }
1492 sb.write(path); 1491 sb.write(path);
1493 _addIfNonEmpty(sb, query, "?", query); 1492 _addIfNonEmpty(sb, query, "?", query);
1494 _addIfNonEmpty(sb, fragment, "#", fragment); 1493 _addIfNonEmpty(sb, fragment, "#", fragment);
1495 return sb.toString(); 1494 return sb.toString();
1496 } 1495 }
1497 1496
1498 bool operator==(other) { 1497 bool operator==(other) {
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
2196 0xafff, // 0x30 - 0x3f 1111111111110101 2195 0xafff, // 0x30 - 0x3f 1111111111110101
2197 // @ABCDEFGHIJKLMNO 2196 // @ABCDEFGHIJKLMNO
2198 0xffff, // 0x40 - 0x4f 1111111111111111 2197 0xffff, // 0x40 - 0x4f 1111111111111111
2199 // PQRSTUVWXYZ _ 2198 // PQRSTUVWXYZ _
2200 0x87ff, // 0x50 - 0x5f 1111111111100001 2199 0x87ff, // 0x50 - 0x5f 1111111111100001
2201 // abcdefghijklmno 2200 // abcdefghijklmno
2202 0xfffe, // 0x60 - 0x6f 0111111111111111 2201 0xfffe, // 0x60 - 0x6f 0111111111111111
2203 // pqrstuvwxyz ~ 2202 // pqrstuvwxyz ~
2204 0x47ff]; // 0x70 - 0x7f 1111111111100010 2203 0x47ff]; // 0x70 - 0x7f 1111111111100010
2205 } 2204 }
OLDNEW
« no previous file with comments | « no previous file | tests/corelib/uri_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698