| 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 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // on the incoming array. | 212 // on the incoming array. |
| 213 var result = new InternalArray(uriLength); | 213 var result = new InternalArray(uriLength); |
| 214 var index = 0; | 214 var index = 0; |
| 215 for (var k = 0; k < uriLength; k++) { | 215 for (var k = 0; k < uriLength; k++) { |
| 216 var ch = uri.charAt(k); | 216 var ch = uri.charAt(k); |
| 217 if (ch == '%') { | 217 if (ch == '%') { |
| 218 if (k + 2 >= uriLength) throw new $URIError("URI malformed"); | 218 if (k + 2 >= uriLength) throw new $URIError("URI malformed"); |
| 219 var cc = URIHexCharsToCharCode(uri.charCodeAt(++k), uri.charCodeAt(++k)); | 219 var cc = URIHexCharsToCharCode(uri.charCodeAt(++k), uri.charCodeAt(++k)); |
| 220 if (cc >> 7) { | 220 if (cc >> 7) { |
| 221 var n = 0; | 221 var n = 0; |
| 222 while (((cc << ++n) & 0x80) != 0) ; | 222 while (((cc << ++n) & 0x80) != 0) { } |
| 223 if (n == 1 || n > 4) throw new $URIError("URI malformed"); | 223 if (n == 1 || n > 4) throw new $URIError("URI malformed"); |
| 224 var octets = new $Array(n); | 224 var octets = new $Array(n); |
| 225 octets[0] = cc; | 225 octets[0] = cc; |
| 226 if (k + 3 * (n - 1) >= uriLength) throw new $URIError("URI malformed"); | 226 if (k + 3 * (n - 1) >= uriLength) throw new $URIError("URI malformed"); |
| 227 for (var i = 1; i < n; i++) { | 227 for (var i = 1; i < n; i++) { |
| 228 if (uri.charAt(++k) != '%') throw new $URIError("URI malformed"); | 228 if (uri.charAt(++k) != '%') throw new $URIError("URI malformed"); |
| 229 octets[i] = URIHexCharsToCharCode(uri.charCodeAt(++k), | 229 octets[i] = URIHexCharsToCharCode(uri.charCodeAt(++k), |
| 230 uri.charCodeAt(++k)); | 230 uri.charCodeAt(++k)); |
| 231 } | 231 } |
| 232 index = URIDecodeOctets(octets, result, index); | 232 index = URIDecodeOctets(octets, result, index); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 260 // / | 260 // / |
| 261 if (cc == 47) return true; | 261 if (cc == 47) return true; |
| 262 // :; | 262 // :; |
| 263 if (58 <= cc && cc <= 59) return true; | 263 if (58 <= cc && cc <= 59) return true; |
| 264 // = | 264 // = |
| 265 if (cc == 61) return true; | 265 if (cc == 61) return true; |
| 266 // ?@ | 266 // ?@ |
| 267 if (63 <= cc && cc <= 64) return true; | 267 if (63 <= cc && cc <= 64) return true; |
| 268 | 268 |
| 269 return false; | 269 return false; |
| 270 }; | 270 } |
| 271 var string = ToString(uri); | 271 var string = ToString(uri); |
| 272 return Decode(string, reservedPredicate); | 272 return Decode(string, reservedPredicate); |
| 273 } | 273 } |
| 274 | 274 |
| 275 | 275 |
| 276 // ECMA-262 - 15.1.3.2. | 276 // ECMA-262 - 15.1.3.2. |
| 277 function URIDecodeComponent(component) { | 277 function URIDecodeComponent(component) { |
| 278 function reservedPredicate(cc) { return false; }; | 278 function reservedPredicate(cc) { return false; } |
| 279 var string = ToString(component); | 279 var string = ToString(component); |
| 280 return Decode(string, reservedPredicate); | 280 return Decode(string, reservedPredicate); |
| 281 } | 281 } |
| 282 | 282 |
| 283 | 283 |
| 284 // Does the char code correspond to an alpha-numeric char. | 284 // Does the char code correspond to an alpha-numeric char. |
| 285 function isAlphaNumeric(cc) { | 285 function isAlphaNumeric(cc) { |
| 286 // a - z | 286 // a - z |
| 287 if (97 <= cc && cc <= 122) return true; | 287 if (97 <= cc && cc <= 122) return true; |
| 288 // A - Z | 288 // A - Z |
| (...skipping 20 matching lines...) Expand all Loading... |
| 309 // = | 309 // = |
| 310 if (cc == 61) return true; | 310 if (cc == 61) return true; |
| 311 // ?@ | 311 // ?@ |
| 312 if (63 <= cc && cc <= 64) return true; | 312 if (63 <= cc && cc <= 64) return true; |
| 313 // _ | 313 // _ |
| 314 if (cc == 95) return true; | 314 if (cc == 95) return true; |
| 315 // ~ | 315 // ~ |
| 316 if (cc == 126) return true; | 316 if (cc == 126) return true; |
| 317 | 317 |
| 318 return false; | 318 return false; |
| 319 }; | 319 } |
| 320 | 320 |
| 321 var string = ToString(uri); | 321 var string = ToString(uri); |
| 322 return Encode(string, unescapePredicate); | 322 return Encode(string, unescapePredicate); |
| 323 } | 323 } |
| 324 | 324 |
| 325 | 325 |
| 326 // ECMA-262 - 15.1.3.4 | 326 // ECMA-262 - 15.1.3.4 |
| 327 function URIEncodeComponent(component) { | 327 function URIEncodeComponent(component) { |
| 328 function unescapePredicate(cc) { | 328 function unescapePredicate(cc) { |
| 329 if (isAlphaNumeric(cc)) return true; | 329 if (isAlphaNumeric(cc)) return true; |
| 330 // ! | 330 // ! |
| 331 if (cc == 33) return true; | 331 if (cc == 33) return true; |
| 332 // '()* | 332 // '()* |
| 333 if (39 <= cc && cc <= 42) return true; | 333 if (39 <= cc && cc <= 42) return true; |
| 334 // -. | 334 // -. |
| 335 if (45 <= cc && cc <= 46) return true; | 335 if (45 <= cc && cc <= 46) return true; |
| 336 // _ | 336 // _ |
| 337 if (cc == 95) return true; | 337 if (cc == 95) return true; |
| 338 // ~ | 338 // ~ |
| 339 if (cc == 126) return true; | 339 if (cc == 126) return true; |
| 340 | 340 |
| 341 return false; | 341 return false; |
| 342 }; | 342 } |
| 343 | 343 |
| 344 var string = ToString(component); | 344 var string = ToString(component); |
| 345 return Encode(string, unescapePredicate); | 345 return Encode(string, unescapePredicate); |
| 346 } | 346 } |
| 347 | 347 |
| 348 | 348 |
| 349 function HexValueOf(code) { | 349 function HexValueOf(code) { |
| 350 // 0-9 | 350 // 0-9 |
| 351 if (code >= 48 && code <= 57) return code - 48; | 351 if (code >= 48 && code <= 57) return code - 48; |
| 352 // A-F | 352 // A-F |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 "escape", URIEscape, | 415 "escape", URIEscape, |
| 416 "unescape", URIUnescape, | 416 "unescape", URIUnescape, |
| 417 "decodeURI", URIDecode, | 417 "decodeURI", URIDecode, |
| 418 "decodeURIComponent", URIDecodeComponent, | 418 "decodeURIComponent", URIDecodeComponent, |
| 419 "encodeURI", URIEncode, | 419 "encodeURI", URIEncode, |
| 420 "encodeURIComponent", URIEncodeComponent | 420 "encodeURIComponent", URIEncodeComponent |
| 421 )); | 421 )); |
| 422 } | 422 } |
| 423 | 423 |
| 424 SetUpUri(); | 424 SetUpUri(); |
| OLD | NEW |