| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 "use strict"; | 5 "use strict"; |
| 6 | 6 |
| 7 // This file relies on the fact that the following declaration has been made | 7 // This file relies on the fact that the following declaration has been made |
| 8 // in runtime.js: | 8 // in runtime.js: |
| 9 // var $Array = global.Array; | 9 // var $Array = global.Array; |
| 10 | 10 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 var highCode = HexValueOf(highChar); | 77 var highCode = HexValueOf(highChar); |
| 78 var lowCode = HexValueOf(lowChar); | 78 var lowCode = HexValueOf(lowChar); |
| 79 if (highCode == -1 || lowCode == -1) { | 79 if (highCode == -1 || lowCode == -1) { |
| 80 throw new $URIError("URI malformed"); | 80 throw new $URIError("URI malformed"); |
| 81 } | 81 } |
| 82 return (highCode << 4) | lowCode; | 82 return (highCode << 4) | lowCode; |
| 83 } | 83 } |
| 84 | 84 |
| 85 | 85 |
| 86 function URIDecodeOctets(octets, result, index) { | 86 function URIDecodeOctets(octets, result, index) { |
| 87 if (!IS_STRING(result)) throw new $URIError("Internal error"); |
| 87 var value; | 88 var value; |
| 88 var o0 = octets[0]; | 89 var o0 = octets[0]; |
| 89 if (o0 < 0x80) { | 90 if (o0 < 0x80) { |
| 90 value = o0; | 91 value = o0; |
| 91 } else if (o0 < 0xc2) { | 92 } else if (o0 < 0xc2) { |
| 92 throw new $URIError("URI malformed"); | 93 throw new $URIError("URI malformed"); |
| 93 } else { | 94 } else { |
| 94 var o1 = octets[1]; | 95 var o1 = octets[1]; |
| 95 if (o0 < 0xe0) { | 96 if (o0 < 0xe0) { |
| 96 var a = o0 & 0x1f; | 97 var a = o0 & 0x1f; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } else { | 142 } else { |
| 142 throw new $URIError("URI malformed"); | 143 throw new $URIError("URI malformed"); |
| 143 } | 144 } |
| 144 } | 145 } |
| 145 } | 146 } |
| 146 } | 147 } |
| 147 if (0xD800 <= value && value <= 0xDFFF) { | 148 if (0xD800 <= value && value <= 0xDFFF) { |
| 148 throw new $URIError("URI malformed"); | 149 throw new $URIError("URI malformed"); |
| 149 } | 150 } |
| 150 if (value < 0x10000) { | 151 if (value < 0x10000) { |
| 152 if (index < 0 || index >= result.length) { |
| 153 throw new $URIError("Internal error"); |
| 154 } |
| 151 %_TwoByteSeqStringSetChar(result, index++, value); | 155 %_TwoByteSeqStringSetChar(result, index++, value); |
| 152 return index; | 156 return index; |
| 153 } else { | 157 } else { |
| 158 if (index < 0 || index >= result.length - 1) { |
| 159 throw new $URIError("Internal error"); |
| 160 } |
| 154 %_TwoByteSeqStringSetChar(result, index++, (value >> 10) + 0xd7c0); | 161 %_TwoByteSeqStringSetChar(result, index++, (value >> 10) + 0xd7c0); |
| 155 %_TwoByteSeqStringSetChar(result, index++, (value & 0x3ff) + 0xdc00); | 162 %_TwoByteSeqStringSetChar(result, index++, (value & 0x3ff) + 0xdc00); |
| 156 return index; | 163 return index; |
| 157 } | 164 } |
| 158 } | 165 } |
| 159 | 166 |
| 160 | 167 |
| 161 // ECMA-262, section 15.1.3 | 168 // ECMA-262, section 15.1.3 |
| 162 function Encode(uri, unescape) { | 169 function Encode(uri, unescape) { |
| 163 var uriLength = uri.length; | 170 var uriLength = uri.length; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 "escape", URIEscapeJS, | 434 "escape", URIEscapeJS, |
| 428 "unescape", URIUnescapeJS, | 435 "unescape", URIUnescapeJS, |
| 429 "decodeURI", URIDecode, | 436 "decodeURI", URIDecode, |
| 430 "decodeURIComponent", URIDecodeComponent, | 437 "decodeURIComponent", URIDecodeComponent, |
| 431 "encodeURI", URIEncode, | 438 "encodeURI", URIEncode, |
| 432 "encodeURIComponent", URIEncodeComponent | 439 "encodeURIComponent", URIEncodeComponent |
| 433 )); | 440 )); |
| 434 } | 441 } |
| 435 | 442 |
| 436 SetUpUri(); | 443 SetUpUri(); |
| OLD | NEW |