| Index: tool/input_sdk/patch/core_patch.dart
|
| diff --git a/tool/input_sdk/patch/core_patch.dart b/tool/input_sdk/patch/core_patch.dart
|
| index 94b58883b57e997a7ab8cc0e627a8d9ac6c8c680..b4dc3c794da8655336d661f98008c5db985c8006 100644
|
| --- a/tool/input_sdk/patch/core_patch.dart
|
| +++ b/tool/input_sdk/patch/core_patch.dart
|
| @@ -392,7 +392,7 @@ class String {
|
| throw new RangeError.range(start, 0, i);
|
| }
|
| }
|
| - var list = [];
|
| + var list = <int>[];
|
| if (end == null) {
|
| while (it.moveNext()) list.add(it.current);
|
| } else {
|
| @@ -556,6 +556,47 @@ class Uri {
|
| if (uri != null) return Uri.parse(uri);
|
| throw new UnsupportedError("'Uri.base' is not supported");
|
| }
|
| +
|
| +
|
| + // Matches a String that _uriEncodes to itself regardless of the kind of
|
| + // component. This corresponds to [_unreservedTable], i.e. characters that
|
| + // are not encoded by any encoding table.
|
| + static final RegExp _needsNoEncoding = new RegExp(r'^[\-\.0-9A-Z_a-z~]*$');
|
| +
|
| + /**
|
| + * This is the internal implementation of JavaScript's encodeURI function.
|
| + * It encodes all characters in the string [text] except for those
|
| + * that appear in [canonicalTable], and returns the escaped string.
|
| + */
|
| + @patch
|
| + static String _uriEncode(List<int> canonicalTable,
|
| + String text,
|
| + Encoding encoding,
|
| + bool spaceToPlus) {
|
| + if (identical(encoding, UTF8) && _needsNoEncoding.hasMatch(text)) {
|
| + return text;
|
| + }
|
| +
|
| + // Encode the string into bytes then generate an ASCII only string
|
| + // by percent encoding selected bytes.
|
| + StringBuffer result = new StringBuffer();
|
| + var bytes = encoding.encode(text);
|
| + for (int i = 0; i < bytes.length; i++) {
|
| + int byte = bytes[i];
|
| + if (byte < 128 &&
|
| + ((canonicalTable[byte >> 4] & (1 << (byte & 0x0f))) != 0)) {
|
| + result.writeCharCode(byte);
|
| + } else if (spaceToPlus && byte == _SPACE) {
|
| + result.write('+');
|
| + } else {
|
| + const String hexDigits = '0123456789ABCDEF';
|
| + result.write('%');
|
| + result.write(hexDigits[(byte >> 4) & 0x0f]);
|
| + result.write(hexDigits[byte & 0x0f]);
|
| + }
|
| + }
|
| + return result.toString();
|
| + }
|
| }
|
|
|
| @patch
|
|
|