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 12 matching lines...) Expand all Loading... |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // This file contains support for URI manipulations written in | 28 // This file contains support for URI manipulations written in |
29 // JavaScript. | 29 // JavaScript. |
30 | 30 |
31 // Expect $String = global.String; | 31 // Expect $String = global.String; |
32 | 32 |
| 33 // Lazily initialized. |
| 34 var hexCharArray = 0; |
| 35 var hexCharCodeArray = 0; |
| 36 |
| 37 |
33 function URIAddEncodedOctetToBuffer(octet, result, index) { | 38 function URIAddEncodedOctetToBuffer(octet, result, index) { |
34 result[index++] = 37; // Char code of '%'. | 39 result[index++] = 37; // Char code of '%'. |
35 result[index++] = hexCharCodeArray[octet >> 4]; | 40 result[index++] = hexCharCodeArray[octet >> 4]; |
36 result[index++] = hexCharCodeArray[octet & 0x0F]; | 41 result[index++] = hexCharCodeArray[octet & 0x0F]; |
37 return index; | 42 return index; |
38 } | 43 } |
39 | 44 |
40 | 45 |
41 function URIEncodeOctets(octets, result, index) { | 46 function URIEncodeOctets(octets, result, index) { |
42 if (hexCharCodeArray === 0) { | 47 if (hexCharCodeArray === 0) { |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 if (cc == 126) return true; | 318 if (cc == 126) return true; |
314 | 319 |
315 return false; | 320 return false; |
316 }; | 321 }; |
317 | 322 |
318 var string = ToString(component); | 323 var string = ToString(component); |
319 return Encode(string, unescapePredicate); | 324 return Encode(string, unescapePredicate); |
320 } | 325 } |
321 | 326 |
322 | 327 |
323 // Lazily initialized. | |
324 var hexCharArray = 0; | |
325 var hexCharCodeArray = 0; | |
326 | |
327 | |
328 function HexValueOf(c) { | 328 function HexValueOf(c) { |
329 var code = c.charCodeAt(0); | 329 var code = c.charCodeAt(0); |
330 | 330 |
331 // 0-9 | 331 // 0-9 |
332 if (code >= 48 && code <= 57) return code - 48; | 332 if (code >= 48 && code <= 57) return code - 48; |
333 // A-F | 333 // A-F |
334 if (code >= 65 && code <= 70) return code - 55; | 334 if (code >= 65 && code <= 70) return code - 55; |
335 // a-f | 335 // a-f |
336 if (code >= 97 && code <= 102) return code - 87; | 336 if (code >= 97 && code <= 102) return code - 87; |
337 | 337 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 "unescape", URIUnescape, | 406 "unescape", URIUnescape, |
407 "decodeURI", URIDecode, | 407 "decodeURI", URIDecode, |
408 "decodeURIComponent", URIDecodeComponent, | 408 "decodeURIComponent", URIDecodeComponent, |
409 "encodeURI", URIEncode, | 409 "encodeURI", URIEncode, |
410 "encodeURIComponent", URIEncodeComponent | 410 "encodeURIComponent", URIEncodeComponent |
411 )); | 411 )); |
412 } | 412 } |
413 | 413 |
414 SetupURI(); | 414 SetupURI(); |
415 | 415 |
OLD | NEW |