Reviewed by Justin Garcia.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Jun 2005 16:48:39 +0000 (16:48 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Jun 2005 16:48:39 +0000 (16:48 +0000)
        - fixed <rdar://problem/4151619> Safari changes "\" characters to "/" in the query part of links that start with "?"

        Test cases added:
        * layout-tests/fast/dom/anchor-backslash-expected.txt: Added.
        * layout-tests/fast/dom/anchor-backslash.html: Added.

        * kwq/KWQKURL.mm: (substituteBackslashes): Fix error where we'd ignore
        "?" and "#" characters if they were the first character in the string.

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

LayoutTests/fast/dom/anchor-backslash-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/anchor-backslash.html [new file with mode: 0644]
WebCore/ChangeLog-2005-08-23
WebCore/kwq/KWQKURL.mm

diff --git a/LayoutTests/fast/dom/anchor-backslash-expected.txt b/LayoutTests/fast/dom/anchor-backslash-expected.txt
new file mode 100644 (file)
index 0000000..1b6723a
--- /dev/null
@@ -0,0 +1,11 @@
+This tests \ characters being changed to / in anchor tags.
+
+If it works you should see five messages below that have \ or / characters as specified.
+
+1 2 3 4 5
+paths like this should turn all \ characters into /: "/a/b/c/"
+query strings like this one should still have \ characters: "?path=\\a\b\c\"
+query strings like this one should still have \ characters even if the URL is only a query: "?path=\\myshare\myfolder\myfile\"
+anchor strings like this one should still have \ characters: "#path=\\a\b\c\"
+anchor strings like this one should still have \ characters even if the URL is only an anchor: "#path=\\myshare\myfolder\myfile\"
+
diff --git a/LayoutTests/fast/dom/anchor-backslash.html b/LayoutTests/fast/dom/anchor-backslash.html
new file mode 100644 (file)
index 0000000..d41f3e3
--- /dev/null
@@ -0,0 +1,34 @@
+<html>
+    <head>
+        <script type="text/javascript">
+            function log(message)
+            {
+                var item = document.createElement("li");
+                item.appendChild(document.createTextNode(message));
+                document.getElementById("console").appendChild(item);
+            }
+            function test()
+            {
+                if (window.layoutTestController)
+                    layoutTestController.dumpAsText();
+                log("paths like this should turn all \\ characters into /: \"" + document.getElementById("1").pathname + "\"");
+                log("query strings like this one should still have \\ characters: \"" + document.getElementById("2").search + "\"");
+                log("query strings like this one should still have \\ characters even if the URL is only a query: \"" + document.getElementById("3").search + "\"");
+                log("anchor strings like this one should still have \\ characters: \"" + document.getElementById("4").hash + "\"");
+                log("anchor strings like this one should still have \\ characters even if the URL is only an anchor: \"" + document.getElementById("5").hash + "\"");
+            }
+       </script>
+    </head>
+    <body onload="test()">
+        <p>This tests \ characters being changed to / in anchor tags.</p>
+        <p>If it works you should see five messages below that have \ or / characters as specified.</p>
+        <hr>
+        <a id="1" href="file:\\\a\b\c\">1</a>
+        <a id="2" href="file:///?path=\\a\b\c\">2</a>
+        <a id="3" href="?path=\\myshare\myfolder\myfile\">3</a>
+        <a id="4" href="file:///#path=\\a\b\c\">4</a>
+        <a id="5" href="#path=\\myshare\myfolder\myfile\">5</a>
+        <hr>
+        <p><ol id="console"></ol></p>
+    </body>
+</html>
index 087882962aa96ae1ef9e8f2bd2be53549cb57984..4a54e2f024dfa2e07334c3130743c533cf7d9478 100644 (file)
@@ -1,3 +1,16 @@
+2005-06-24  Darin Adler  <darin@apple.com>
+
+        Reviewed by Justin Garcia.
+
+        - fixed <rdar://problem/4151619> Safari changes "\" characters to "/" in the query part of links that start with "?"
+
+        Test cases added:
+        * layout-tests/fast/dom/anchor-backslash-expected.txt: Added.
+        * layout-tests/fast/dom/anchor-backslash.html: Added.
+
+        * kwq/KWQKURL.mm: (substituteBackslashes): Fix error where we'd ignore
+        "?" and "#" characters if they were the first character in the string.
+
 2005-06-23  Darin Adler  <darin@apple.com>
 
         * khtml/html/html_formimpl.cpp: (DOM::HTMLTextAreaElementImpl::setValue):
index 2368fb0740b043ccf5263c00e8cd1e4499c7c5ad..58a513cdf57a4f847919d4631c8243052f14d8fd 100644 (file)
@@ -1733,9 +1733,9 @@ static QString substituteBackslashes(const QString &string)
     int hashPos = string.find('#');
     unsigned pathEnd;
     
-    if (hashPos > 0 && (questionPos < 0 || questionPos > hashPos)) {
+    if (hashPos >= 0 && (questionPos < 0 || questionPos > hashPos)) {
        pathEnd = hashPos;
-    } else if (questionPos > 0) {
+    } else if (questionPos >= 0) {
        pathEnd = questionPos;
     } else {
        pathEnd = string.length();