diff options
Diffstat (limited to 'deps/v8/src/uri.js')
-rw-r--r-- | deps/v8/src/uri.js | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/deps/v8/src/uri.js b/deps/v8/src/uri.js index 179fa92863..e94b3fe56a 100644 --- a/deps/v8/src/uri.js +++ b/deps/v8/src/uri.js @@ -90,11 +90,13 @@ function URIEncodePair(cc1 , cc2, result, index) { } -function URIHexCharsToCharCode(ch1, ch2) { - if (HexValueOf(ch1) == -1 || HexValueOf(ch2) == -1) { +function URIHexCharsToCharCode(highChar, lowChar) { + var highCode = HexValueOf(highChar); + var lowCode = HexValueOf(lowChar); + if (highCode == -1 || lowCode == -1) { throw new $URIError("URI malformed"); } - return HexStrToCharCode(ch1 + ch2); + return (highCode << 4) | lowCode; } @@ -196,7 +198,7 @@ function Decode(uri, reserved) { var ch = uri.charAt(k); if (ch == '%') { if (k + 2 >= uriLength) throw new $URIError("URI malformed"); - var cc = URIHexCharsToCharCode(uri.charAt(++k), uri.charAt(++k)); + var cc = URIHexCharsToCharCode(uri.charCodeAt(++k), uri.charCodeAt(++k)); if (cc >> 7) { var n = 0; while (((cc << ++n) & 0x80) != 0) ; @@ -206,7 +208,7 @@ function Decode(uri, reserved) { if (k + 3 * (n - 1) >= uriLength) throw new $URIError("URI malformed"); for (var i = 1; i < n; i++) { if (uri.charAt(++k) != '%') throw new $URIError("URI malformed"); - octets[i] = URIHexCharsToCharCode(uri.charAt(++k), uri.charAt(++k)); + octets[i] = URIHexCharsToCharCode(uri.charCodeAt(++k), uri.charCodeAt(++k)); } index = URIDecodeOctets(octets, result, index); } else { @@ -325,9 +327,7 @@ function URIEncodeComponent(component) { } -function HexValueOf(c) { - var code = c.charCodeAt(0); - +function HexValueOf(code) { // 0-9 if (code >= 48 && code <= 57) return code - 48; // A-F @@ -356,18 +356,6 @@ function CharCodeToHex4Str(cc) { } -// Converts hex string to char code. Not efficient. -function HexStrToCharCode(s) { - var m = 0; - var r = 0; - for (var i = s.length - 1; i >= 0; --i) { - r = r + (HexValueOf(s.charAt(i)) << m); - m = m + 4; - } - return r; -} - - // Returns true if all digits in string s are valid hex numbers function IsValidHex(s) { for (var i = 0; i < s.length; ++i) { |