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

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

Issue 532273002: Fix scheme's toLowerCase detection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cleanup. Created 6 years, 3 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_scheme_test.dart » ('j') | tests/corelib/uri_scheme_test.dart » ('J')
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 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 return buffer.toString(); 1095 return buffer.toString();
1096 } 1096 }
1097 1097
1098 /** 1098 /**
1099 * Validates scheme characters and does case-normalization. 1099 * Validates scheme characters and does case-normalization.
1100 * 1100 *
1101 * Schemes are converted to lower case. They cannot contain escapes. 1101 * Schemes are converted to lower case. They cannot contain escapes.
1102 */ 1102 */
1103 static String _makeScheme(String scheme, int end) { 1103 static String _makeScheme(String scheme, int end) {
1104 if (end == 0) return ""; 1104 if (end == 0) return "";
1105 int char = scheme.codeUnitAt(0); 1105 final int firstCodeUnit = scheme.codeUnitAt(0);
1106 if (!_isAlphabeticCharacter(char)) { 1106 if (!_isAlphabeticCharacter(firstCodeUnit)) {
1107 _fail(scheme, 0, "Scheme not starting with alphabetic character"); 1107 _fail(scheme, 0, "Scheme not starting with alphabetic character");
1108 } 1108 }
1109 bool allLowercase = char >= _LOWER_CASE_A; 1109 bool allLowercase = firstCodeUnit >= _LOWER_CASE_A;
1110 for (int i = 0; i < end; i++) { 1110 for (int i = 0; i < end; i++) {
1111 int codeUnit = scheme.codeUnitAt(i); 1111 final int codeUnit = scheme.codeUnitAt(i);
1112 if (!_isSchemeCharacter(codeUnit)) { 1112 if (!_isSchemeCharacter(codeUnit)) {
1113 _fail(scheme, i, "Illegal scheme character"); 1113 _fail(scheme, i, "Illegal scheme character");
1114 } 1114 }
1115 if (_LOWER_CASE_A <= char && _LOWER_CASE_Z >= char) { 1115 if (codeUnit < _LOWER_CASE_A || codeUnit > _LOWER_CASE_Z) {
Lasse Reichstein Nielsen 2014/09/04 05:57:14 whoops.
Anders Johnsen 2014/09/04 06:27:57 Heh, copy paste :)
1116 allLowercase = false; 1116 allLowercase = false;
1117 } 1117 }
1118 } 1118 }
1119 scheme = scheme.substring(0, end); 1119 scheme = scheme.substring(0, end);
Lasse Reichstein Nielsen 2014/09/04 05:57:14 It really, really sucks that we don't have cheap s
Anders Johnsen 2014/09/04 06:27:57 That's not a bad idea. Lets discuss it offline.
1120 if (!allLowercase) scheme = scheme.toLowerCase(); 1120 if (!allLowercase) scheme = scheme.toLowerCase();
1121 return scheme; 1121 return scheme;
1122 } 1122 }
1123 1123
1124 static String _makeUserInfo(String userInfo, int start, int end) { 1124 static String _makeUserInfo(String userInfo, int start, int end) {
1125 if (userInfo == null) return ""; 1125 if (userInfo == null) return "";
1126 return _normalize(userInfo, start, end, _userinfoTable); 1126 return _normalize(userInfo, start, end, _userinfoTable);
1127 } 1127 }
1128 1128
1129 static String _makePath(String path, int start, int end, 1129 static String _makePath(String path, int start, int end,
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after
2368 0xafff, // 0x30 - 0x3f 1111111111110101 2368 0xafff, // 0x30 - 0x3f 1111111111110101
2369 // @ABCDEFGHIJKLMNO 2369 // @ABCDEFGHIJKLMNO
2370 0xffff, // 0x40 - 0x4f 1111111111111111 2370 0xffff, // 0x40 - 0x4f 1111111111111111
2371 // PQRSTUVWXYZ _ 2371 // PQRSTUVWXYZ _
2372 0x87ff, // 0x50 - 0x5f 1111111111100001 2372 0x87ff, // 0x50 - 0x5f 1111111111100001
2373 // abcdefghijklmno 2373 // abcdefghijklmno
2374 0xfffe, // 0x60 - 0x6f 0111111111111111 2374 0xfffe, // 0x60 - 0x6f 0111111111111111
2375 // pqrstuvwxyz ~ 2375 // pqrstuvwxyz ~
2376 0x47ff]; // 0x70 - 0x7f 1111111111100010 2376 0x47ff]; // 0x70 - 0x7f 1111111111100010
2377 } 2377 }
OLDNEW
« no previous file with comments | « no previous file | tests/corelib/uri_scheme_test.dart » ('j') | tests/corelib/uri_scheme_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698