Chromium Code Reviews| 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 2233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2244 static const int _UPPER_CASE_F = 0x46; | 2244 static const int _UPPER_CASE_F = 0x46; |
| 2245 static const int _UPPER_CASE_Z = 0x5A; | 2245 static const int _UPPER_CASE_Z = 0x5A; |
| 2246 static const int _LEFT_BRACKET = 0x5B; | 2246 static const int _LEFT_BRACKET = 0x5B; |
| 2247 static const int _BACKSLASH = 0x5C; | 2247 static const int _BACKSLASH = 0x5C; |
| 2248 static const int _RIGHT_BRACKET = 0x5D; | 2248 static const int _RIGHT_BRACKET = 0x5D; |
| 2249 static const int _LOWER_CASE_A = 0x61; | 2249 static const int _LOWER_CASE_A = 0x61; |
| 2250 static const int _LOWER_CASE_F = 0x66; | 2250 static const int _LOWER_CASE_F = 0x66; |
| 2251 static const int _LOWER_CASE_Z = 0x7A; | 2251 static const int _LOWER_CASE_Z = 0x7A; |
| 2252 static const int _BAR = 0x7C; | 2252 static const int _BAR = 0x7C; |
| 2253 | 2253 |
| 2254 // Matches a String that _uriEncodes to itself regardless of the kind of | |
| 2255 // component. This corresponds to [_unreservedTable]. | |
| 2256 static final RegExp _needsNoEncoding = new RegExp(r'^[\-\.0-9A-Z_a-z~]*$'); | |
|
Ivan Posva
2015/11/04 05:11:50
Please refrain from using RegExp in core library c
| |
| 2257 | |
| 2254 /** | 2258 /** |
| 2255 * This is the internal implementation of JavaScript's encodeURI function. | 2259 * This is the internal implementation of JavaScript's encodeURI function. |
| 2256 * It encodes all characters in the string [text] except for those | 2260 * It encodes all characters in the string [text] except for those |
| 2257 * that appear in [canonicalTable], and returns the escaped string. | 2261 * that appear in [canonicalTable], and returns the escaped string. |
| 2258 */ | 2262 */ |
| 2259 static String _uriEncode(List<int> canonicalTable, | 2263 static String _uriEncode(List<int> canonicalTable, |
| 2260 String text, | 2264 String text, |
| 2261 {Encoding encoding: UTF8, | 2265 {Encoding encoding: UTF8, |
| 2262 bool spaceToPlus: false}) { | 2266 bool spaceToPlus: false}) { |
| 2267 if (_needsNoEncoding.hasMatch(text)) return text; | |
|
Lasse Reichstein Nielsen
2015/11/03 07:08:19
This should be a regexp that matches canonicalTabl
Lasse Reichstein Nielsen
2015/11/03 07:12:08
Ah, finally realized that the only characters used
Lasse Reichstein Nielsen
2015/11/04 08:32:41
Only do this if encoding is UTF8, LATIN1 or ASCII
| |
| 2268 | |
| 2263 byteToHex(byte, buffer) { | 2269 byteToHex(byte, buffer) { |
| 2264 const String hex = '0123456789ABCDEF'; | 2270 const String hex = '0123456789ABCDEF'; |
| 2265 buffer.writeCharCode(hex.codeUnitAt(byte >> 4)); | 2271 buffer.writeCharCode(hex.codeUnitAt(byte >> 4)); |
| 2266 buffer.writeCharCode(hex.codeUnitAt(byte & 0x0f)); | 2272 buffer.writeCharCode(hex.codeUnitAt(byte & 0x0f)); |
| 2267 } | 2273 } |
| 2268 | 2274 |
| 2269 // Encode the string into bytes then generate an ASCII only string | 2275 // Encode the string into bytes then generate an ASCII only string |
| 2270 // by percent encoding selected bytes. | 2276 // by percent encoding selected bytes. |
| 2271 StringBuffer result = new StringBuffer(); | 2277 StringBuffer result = new StringBuffer(); |
| 2272 var bytes = encoding.encode(text); | 2278 var bytes = encoding.encode(text); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2604 0xafff, // 0x30 - 0x3f 1111111111110101 | 2610 0xafff, // 0x30 - 0x3f 1111111111110101 |
| 2605 // @ABCDEFGHIJKLMNO | 2611 // @ABCDEFGHIJKLMNO |
| 2606 0xffff, // 0x40 - 0x4f 1111111111111111 | 2612 0xffff, // 0x40 - 0x4f 1111111111111111 |
| 2607 // PQRSTUVWXYZ _ | 2613 // PQRSTUVWXYZ _ |
| 2608 0x87ff, // 0x50 - 0x5f 1111111111100001 | 2614 0x87ff, // 0x50 - 0x5f 1111111111100001 |
| 2609 // abcdefghijklmno | 2615 // abcdefghijklmno |
| 2610 0xfffe, // 0x60 - 0x6f 0111111111111111 | 2616 0xfffe, // 0x60 - 0x6f 0111111111111111 |
| 2611 // pqrstuvwxyz ~ | 2617 // pqrstuvwxyz ~ |
| 2612 0x47ff]; // 0x70 - 0x7f 1111111111100010 | 2618 0x47ff]; // 0x70 - 0x7f 1111111111100010 |
| 2613 } | 2619 } |
| OLD | NEW |