Reviewed by Hyatt.
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 18 Feb 2007 12:48:44 +0000 (12:48 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 18 Feb 2007 12:48:44 +0000 (12:48 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=12799
        REGRESSION: Webpage doesn't load correctly (www.cincinnati.com
        redirects to the wrong URL)

        Test: http/tests/misc/refresh-meta-with-newline.html

        * platform/network/HTTPParsers.cpp:
        (WebCore::skipWhiteSpace):
        (WebCore::parseHTTPRefresh):
        * platform/network/HTTPParsers.h:
        In HTML, all characters with codes <= 0x20 are whitespace, while in
        HTTP, only space and tab are such.

        * dom/Document.cpp:
        (WebCore::Document::processHttpEquiv):
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::receivedFirstData):
        Pass parseHTTPRefresh() a flag telling about the source of data.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@19691 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/misc/refresh-meta-with-newline-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/misc/refresh-meta-with-newline.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/Document.cpp
WebCore/loader/FrameLoader.cpp
WebCore/platform/network/HTTPParsers.cpp
WebCore/platform/network/HTTPParsers.h

index ca7de5a..a01ad6f 100644 (file)
@@ -1,3 +1,14 @@
+2007-02-18  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Hyatt.
+
+        http://bugs.webkit.org/show_bug.cgi?id=12799
+        REGRESSION: Webpage doesn't load correctly (www.cincinnati.com
+        redirects to the wrong URL)
+
+        * http/tests/misc/refresh-meta-with-newline-expected.txt: Added.
+        * http/tests/misc/refresh-meta-with-newline.html: Added.
+
 2007-02-17  Lars Knoll <lars@trolltech.com>
 
         Reviewed by Adam.
diff --git a/LayoutTests/http/tests/misc/refresh-meta-with-newline-expected.txt b/LayoutTests/http/tests/misc/refresh-meta-with-newline-expected.txt
new file mode 100644 (file)
index 0000000..ff43ca4
--- /dev/null
@@ -0,0 +1 @@
+SUCCESS
diff --git a/LayoutTests/http/tests/misc/refresh-meta-with-newline.html b/LayoutTests/http/tests/misc/refresh-meta-with-newline.html
new file mode 100644 (file)
index 0000000..0720a1e
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+<head>
+<META   HTTP-EQUIV      = "Refresh"
+                Content = "0;\r
+\ 1\ 2\ 3\ 4\ 5\ 6\a\b       \v\f\ e\ f\10\11\12\13\14\15\16\17\18\19\1a\e\1c\1d\1e\1f                URL=resources/200.html">
+
+</head>
+<body>
+<p><a href="http://bugs.webkit.org/show_bug.cgi?id=12799">Bug 12799</a>.</p>
+<p>FAILURE (should redirect).</p>
+<script>
+if (window.layoutTestController) {
+  layoutTestController.dumpAsText();
+  layoutTestController.waitUntilDone();
+}
+</script>
+</body>
+</html>
index b154fb8..55136f9 100644 (file)
@@ -1,3 +1,26 @@
+2007-02-18  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Hyatt.
+
+        http://bugs.webkit.org/show_bug.cgi?id=12799
+        REGRESSION: Webpage doesn't load correctly (www.cincinnati.com
+        redirects to the wrong URL)
+
+        Test: http/tests/misc/refresh-meta-with-newline.html
+
+        * platform/network/HTTPParsers.cpp:
+        (WebCore::skipWhiteSpace):
+        (WebCore::parseHTTPRefresh):
+        * platform/network/HTTPParsers.h:
+        In HTML, all characters with codes <= 0x20 are whitespace, while in
+        HTTP, only space and tab are such.
+
+        * dom/Document.cpp:
+        (WebCore::Document::processHttpEquiv):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::receivedFirstData):
+        Pass parseHTTPRefresh() a flag telling about the source of data.
+
 2007-02-18  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by NOBODY (Build fix).
index 0c0dc61..2736bed 100644 (file)
@@ -1686,7 +1686,7 @@ void Document::processHttpEquiv(const String &equiv, const String &content)
     } else if (equalIgnoringCase(equiv, "refresh")) {
         double delay;
         String url;
-        if (frame && parseHTTPRefresh(content, delay, url)) {
+        if (frame && parseHTTPRefresh(content, true, delay, url)) {
             if (url.isEmpty())
                 frame->loader()->scheduleRedirection(delay, frame->loader()->url().url(), delay <= 1);
             else
index 42d7c59..3675998 100644 (file)
@@ -777,7 +777,7 @@ void FrameLoader::receivedFirstData()
     double delay;
     String URL;
 
-    if (!parseHTTPRefresh(refresh, delay, URL))
+    if (!parseHTTPRefresh(refresh, false, delay, URL))
         return;
 
     if (URL.isEmpty())
index 886d709..3d418ca 100644 (file)
 namespace WebCore {
 
 // true if there is more to parse
-static inline bool skipWhiteSpace(const String& str, int& pos)
+static inline bool skipWhiteSpace(const String& str, int& pos, bool fromHttpEquivMeta)
 {
     int len = str.length();
 
-    while (pos != len && (str[pos] == '\t' || str[pos] == ' '))
-        ++pos;
+    if (fromHttpEquivMeta)
+        while (pos != len && str[pos] <= ' ')
+            ++pos;
+    else
+        while (pos != len && (str[pos] == '\t' || str[pos] == ' '))
+            ++pos;
+
     return pos != len;
 }
 
-bool parseHTTPRefresh(const String& refresh, double& delay, String& url)
+bool parseHTTPRefresh(const String& refresh, bool fromHttpEquivMeta, double& delay, String& url)
 {
     int len = refresh.length();
     int pos = 0;
     
-    if (!skipWhiteSpace(refresh, pos))
+    if (!skipWhiteSpace(refresh, pos, fromHttpEquivMeta))
         return false;
     
     while (pos != len && refresh[pos] != ',' && refresh[pos] != ';')
@@ -66,14 +71,14 @@ bool parseHTTPRefresh(const String& refresh, double& delay, String& url)
             return false;
         
         ++pos;
-        skipWhiteSpace(refresh, pos);
+        skipWhiteSpace(refresh, pos, fromHttpEquivMeta);
         int urlStartPos = pos;
         if (refresh.find("url", urlStartPos, false) == urlStartPos) {
             urlStartPos += 3;
-            skipWhiteSpace(refresh, urlStartPos);
+            skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta);
             if (refresh[urlStartPos] == '=') {
                 ++urlStartPos;
-                skipWhiteSpace(refresh, urlStartPos);
+                skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta);
             } else
                 urlStartPos = pos;  // e.g. "Refresh: 0; url.html"
         }
index ea41ce1..e13b282 100644 (file)
@@ -33,7 +33,7 @@ namespace WebCore {
 
     class String;
 
-    bool parseHTTPRefresh(const String& refresh, double& delay, String& url);
+    bool parseHTTPRefresh(const String& refresh, bool fromHttpEquivMeta, double& delay, String& url);
 }
 
 #endif