* Do the percent replacement only when we are not base64. With base64 we should not...
authorhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Oct 2007 13:40:42 +0000 (13:40 +0000)
committerhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Oct 2007 13:40:42 +0000 (13:40 +0000)
* Have a custom decodePercentEncoding method that works without doing any charset conversion. With converting back to latin1() we lost some information.
* We pass the char-decoding.html test now

Signed-off-by: Simon Hausmann <hausmann@kde.org>
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27038 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/qt/Skipped
WebKit/qt/Api/qwebnetworkinterface.cpp
WebKit/qt/ChangeLog

index 2125135804cc9766e76bc5cb9b7328ebeca91bbb..a9bb464b6d48e627c7582e8f9908848befad5055 100644 (file)
@@ -1,3 +1,14 @@
+2007-10-25  Holger Freyther  <zecke@selfish.org>
+
+        Reviewed by Simon Hausmann <hausmann@kde.org>.
+
+        * Do the percent replacement only when we are not base64. With base64 we should not have any % in it anyway.
+        * Have a custom decodePercentEncoding method that works without doing any charset conversion. With converting back to latin1() we lost some information.
+        * We pass the char-decoding.html test now
+        
+
+        * platform/qt/Skipped:
+
 2007-10-25  Geoffrey Garen  <ggaren@apple.com>
 
         Layout tests for bugs that might result from changes like 
index 7865acee2cdd3ebd0a19e3b3e32c732fd1f0057a..817e594cb99bc92df20059ae62f37b16d003a4ae 100644 (file)
@@ -85,10 +85,6 @@ fast/encoding/meta-in-xhtml.xhtml
 fast/dom/Window/get-set-properties.html
 fast/dom/Window/window-properties.html
 
-# ------- tests that require synchrounous XmlHttpRequest
-fast/encoding/char-decoding.html
-
-
 # ------- failures for tests with results
 fast/dom/xmlhttprequest-html-response-encoding.html
 fast/dom/Window/window-early-properties.html
index 0b2a365eed971e29154511092b3f3661a693cd12..6dff52cf473fe69f2dd66f37d00c3509f231c31d 100644 (file)
@@ -64,6 +64,47 @@ static bool operator==(const HostInfo &i1, const HostInfo &i2)
     return i1.port == i2.port && i1.host == i2.host;
 }
 
+enum ParserState {
+    State_Begin,
+    State_FirstChar,
+    State_SecondChar
+};
+
+/*
+ * Decode URLs without doing any charset conversion.
+ *
+ * Most simple approach to do it without any lookahead.
+ */
+static QByteArray decodePercentEncoding(const QByteArray& input)
+{
+    int actualLength = 0;
+    QByteArray tmpVal;
+    QByteArray output;
+    ParserState state = State_Begin;
+
+    output.resize(input.length());
+    tmpVal.resize(2);
+
+    for (int i = 0; i < input.length(); ++i)
+        if (state == State_Begin) {
+            if (input.at(i) == '%') {
+                state = State_FirstChar;
+            } else {
+                output[actualLength++] = input[i];
+            }
+        } else if (state == State_FirstChar) {
+            state = State_SecondChar;
+            tmpVal[0] = input[i];
+        } else if (state == State_SecondChar) {
+            state = State_Begin;
+            tmpVal[1] = input[i];
+            output[actualLength++] = tmpVal.toShort(0, 16);
+        }
+
+    output.resize(actualLength);
+    return output;
+}
+
 void QWebNetworkRequestPrivate::init(const WebCore::ResourceRequest &resourceRequest)
 {
     KURL url = resourceRequest.url();
@@ -638,9 +679,11 @@ void QWebNetworkInterfacePrivate::parseDataUrl(QWebNetworkJob* job)
     } else {
         data = QByteArray();
     }
-    data = QUrl::fromPercentEncoding(data).toLatin1();
+
     if (base64) {
         data = QByteArray::fromBase64(data);
+    } else {
+        data = decodePercentEncoding(data);
     }
 
     if (header.isEmpty())
index b8e1ad5ccd9b951a688b2bf18a3bcf503915dad9..2bb2729e9bd64b9541361e342eae1e389152c748 100644 (file)
@@ -1,3 +1,16 @@
+2007-10-25  Holger Freyther  <zecke@selfish.org>
+
+        Reviewed by Simon Hausmann <hausmann@kde.org>.
+
+        * Do the percent replacement only when we are not base64. With base64 we should not have any % in it anyway.
+        * Have a custom decodePercentEncoding method that works without doing any charset conversion. With converting back to latin1() we lost some information.
+        * We pass the char-decoding.html test now
+        
+
+        * Api/qwebnetworkinterface.cpp:
+        (decodePercentEncoding):
+        (QWebNetworkInterfacePrivate::parseDataUrl):
+
 2007-10-24  Holger Hans Peter Freyther  <zecke@selfish.org>
 
         Reviewed by Lars Knoll <lars@trolltech.com>.