OLD | NEW |
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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 break; | 493 break; |
494 } | 494 } |
495 if (char == _SLASH) { | 495 if (char == _SLASH) { |
496 state = (i == start) ? ALLOW_AUTH : IN_PATH; | 496 state = (i == start) ? ALLOW_AUTH : IN_PATH; |
497 break; | 497 break; |
498 } | 498 } |
499 if (char == _COLON) { | 499 if (char == _COLON) { |
500 if (i == start) _fail(uri, start, "Invalid empty scheme"); | 500 if (i == start) _fail(uri, start, "Invalid empty scheme"); |
501 scheme = _makeScheme(uri, start, i); | 501 scheme = _makeScheme(uri, start, i); |
502 i++; | 502 i++; |
| 503 if (scheme == "data") { |
| 504 // This generates a URI that is (potentially) not path normalized. |
| 505 // Applying part normalization to a non-hierarchial URI isn't |
| 506 // meaningful. |
| 507 return UriData._parse(uri, i, null).uri; |
| 508 } |
503 pathStart = i; | 509 pathStart = i; |
504 if (i == end) { | 510 if (i == end) { |
505 char = EOI; | 511 char = EOI; |
506 state = NOT_IN_PATH; | 512 state = NOT_IN_PATH; |
507 } else { | 513 } else { |
508 char = uri.codeUnitAt(i); | 514 char = uri.codeUnitAt(i); |
509 if (char == _QUESTION || char == _NUMBER_SIGN) { | 515 if (char == _QUESTION || char == _NUMBER_SIGN) { |
510 state = NOT_IN_PATH; | 516 state = NOT_IN_PATH; |
511 } else if (char == _SLASH) { | 517 } else if (char == _SLASH) { |
512 state = ALLOW_AUTH; | 518 state = ALLOW_AUTH; |
(...skipping 2520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3033 String path = _text; | 3039 String path = _text; |
3034 String query = null; | 3040 String query = null; |
3035 int colonIndex = _separatorIndices[0]; | 3041 int colonIndex = _separatorIndices[0]; |
3036 int queryIndex = _text.indexOf('?', colonIndex + 1); | 3042 int queryIndex = _text.indexOf('?', colonIndex + 1); |
3037 int end = null; | 3043 int end = null; |
3038 if (queryIndex >= 0) { | 3044 if (queryIndex >= 0) { |
3039 query = _text.substring(queryIndex + 1); | 3045 query = _text.substring(queryIndex + 1); |
3040 end = queryIndex; | 3046 end = queryIndex; |
3041 } | 3047 } |
3042 path = _text.substring(colonIndex + 1, end); | 3048 path = _text.substring(colonIndex + 1, end); |
3043 // TODO(lrn): This is probably too simple. We should ensure URI | 3049 // TODO(lrn): This can generate a URI that isn't path normalized. |
3044 // normalization before passing in the raw strings, maybe using | 3050 // That's perfectly reasonable - data URIs are not hierarchical, |
3045 // Uri._makePath, Uri._makeQuery. | 3051 // but it may make some consumers stumble. |
| 3052 // Should we at least do escape normalization? |
3046 _uriCache = new Uri._internal("data", "", null, null, path, query, null); | 3053 _uriCache = new Uri._internal("data", "", null, null, path, query, null); |
3047 return _uriCache; | 3054 return _uriCache; |
3048 } | 3055 } |
3049 | 3056 |
3050 /** | 3057 /** |
3051 * The MIME type of the data URI. | 3058 * The MIME type of the data URI. |
3052 * | 3059 * |
3053 * A data URI consists of a "media type" followed by data. | 3060 * A data URI consists of a "media type" followed by data. |
3054 * The media type starts with a MIME type and can be followed by | 3061 * The media type starts with a MIME type and can be followed by |
3055 * extra parameters. | 3062 * extra parameters. |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3345 // All non-escape RFC-2396 uric characters. | 3352 // All non-escape RFC-2396 uric characters. |
3346 // | 3353 // |
3347 // uric = reserved | unreserved | escaped | 3354 // uric = reserved | unreserved | escaped |
3348 // reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," | 3355 // reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," |
3349 // unreserved = alphanum | mark | 3356 // unreserved = alphanum | mark |
3350 // mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")" | 3357 // mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")" |
3351 // | 3358 // |
3352 // This is the same characters as in a URI query (which is URI pchar plus '?') | 3359 // This is the same characters as in a URI query (which is URI pchar plus '?') |
3353 static const _uricTable = Uri._queryCharTable; | 3360 static const _uricTable = Uri._queryCharTable; |
3354 } | 3361 } |
OLD | NEW |