From 967717af5423377c967781471ee106e2bb4e11c8 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Thu, 22 Jul 2010 15:37:06 +0100 Subject: Merge WebKit at r63859 : Initial merge by git. Change-Id: Ie8096c63ec7c991c9a9cba8bdd9c3b74a3b8ed62 --- WebCore/platform/KURLGoogle.cpp | 53 ++++------------------------------------- 1 file changed, 5 insertions(+), 48 deletions(-) (limited to 'WebCore/platform/KURLGoogle.cpp') diff --git a/WebCore/platform/KURLGoogle.cpp b/WebCore/platform/KURLGoogle.cpp index b4c84a6..ac02630 100644 --- a/WebCore/platform/KURLGoogle.cpp +++ b/WebCore/platform/KURLGoogle.cpp @@ -48,7 +48,6 @@ #include #include -#include #include using WTF::isASCIILower; @@ -943,55 +942,13 @@ String decodeURLEscapeSequences(const String& str, const TextEncoding& encoding) const char* input = cstr.data(); int inputLength = cstr.length(); - url_canon::RawCanonOutputT unescaped; - for (int i = 0; i < inputLength; i++) { - if (input[i] == '%') { - unsigned char ch; - if (url_canon::DecodeEscaped(input, &i, inputLength, &ch)) - unescaped.push_back(ch); - else { - // Invalid escape sequence, copy the percent literal. - unescaped.push_back('%'); - } - } else { - // Regular non-escaped 8-bit character. - unescaped.push_back(input[i]); - } - } - // Convert that 8-bit to UTF-16. It's not clear IE does this at all to - // JavaScript URLs, but Firefox and Safari do. - url_canon::RawCanonOutputT utf16; - for (int i = 0; i < unescaped.length(); i++) { - unsigned char uch = static_cast(unescaped.at(i)); - if (uch < 0x80) { - // Non-UTF-8, just append directly - utf16.push_back(uch); - } else { - // next_ch will point to the last character of the decoded - // character. - int nextCharacter = i; - unsigned codePoint; - if (url_canon::ReadUTFChar(unescaped.data(), &nextCharacter, - unescaped.length(), &codePoint)) { - // Valid UTF-8 character, convert to UTF-16. - url_canon::AppendUTF16Value(codePoint, &utf16); - i = nextCharacter; - } else { - // KURL.cpp strips any sequences that are not valid UTF-8. This - // sounds scary. Instead, we just keep those invalid code - // points and promote to UTF-16. We copy all characters from - // the current position to the end of the identified sqeuqnce. - while (i < nextCharacter) { - utf16.push_back(static_cast(unescaped.at(i))); - i++; - } - utf16.push_back(static_cast(unescaped.at(i))); - } - } - } + url_canon::RawCanonOutputT unescaped; + + url_util::DecodeURLEscapeSequences(input, inputLength, &unescaped); - return String(reinterpret_cast(utf16.data()), utf16.length()); + return String(reinterpret_cast(unescaped.data()), + unescaped.length()); } bool KURL::protocolIs(const char* protocol) const -- cgit v1.1