LayoutTests:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Sep 2006 17:38:39 +0000 (17:38 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Sep 2006 17:38:39 +0000 (17:38 +0000)
        Reviewed by Darin.

        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=10323
          REGRESSION: javascript: URL containing '\\' gets passed as '//'

        * fast/dom/javascript-backslash-expected.txt: Added.
        * fast/dom/javascript-backslash.html: Added.

WebCore:

        Reviewed by Darin.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=10323
          REGRESSION: javascript: URL containing '\\' gets passed as '//'

        Test: fast/dom/javascript-backslash.html

        * platform/KURL.cpp: (WebCore::KURL::init): Don't do backslash
        substitution in JavaScript URLs.

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

LayoutTests/ChangeLog
LayoutTests/fast/dom/javascript-backslash-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/javascript-backslash.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/platform/KURL.cpp

index 80df0c784bc206713bbd4ab0d8e9d07bee324884..fc037d995e2dd928377004806ee065bdfda013ff 100644 (file)
@@ -1,3 +1,13 @@
+2006-09-11  Vladimir Olexa  <vladimir.olexa@gmail.com>
+
+        Reviewed by Darin.
+
+        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=10323
+          REGRESSION: javascript: URL containing '\\' gets passed as '//'
+
+        * fast/dom/javascript-backslash-expected.txt: Added.
+        * fast/dom/javascript-backslash.html: Added.
+
 2006-09-11  Darin Adler  <darin@apple.com>
 
         - converted a test to plain text (makes it platform independent; fixes a failure)
diff --git a/LayoutTests/fast/dom/javascript-backslash-expected.txt b/LayoutTests/fast/dom/javascript-backslash-expected.txt
new file mode 100644 (file)
index 0000000..bd9c022
--- /dev/null
@@ -0,0 +1,13 @@
+This tests \ characters being changed to / in all different scenarios.
+
+If it works you should see seven messages below that have \ or / characters as specified.
+
+1 2 3 4 5 6 7
+javascript: function argument containing a backslash (\) should not be converted to a slash (/): "alert('to be\\not')"
+http: base should convert a \ to a / : "http://apple.com/support"
+https: base should also convert a \ to a / : "https://login.apple.com/support/"
+file: base should convert a \ to a / : "file:///Users/"
+any other valid base except javascript: should convert a \ to a / : "ftp://apple.com/support/"
+query strings should be left alone: "http://apple.com/support?path=\\myshare\myfolder\myfile\"
+anchors should be left alone as well: "http://apple.com/support#path=\\myshare\myfolder\myfile\"
+
diff --git a/LayoutTests/fast/dom/javascript-backslash.html b/LayoutTests/fast/dom/javascript-backslash.html
new file mode 100644 (file)
index 0000000..91d9071
--- /dev/null
@@ -0,0 +1,38 @@
+<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("javascript: function argument containing a backslash (\\) should not be converted to a slash (/): \"" + document.getElementById("1").pathname + "\"");
+                log("http: base should convert a \\ to a / : \"" + document.getElementById("2").href + "\"");
+                log("https: base should also convert a \\ to a / : \"" + document.getElementById("3").href + "\"");
+                log("file: base should convert a \\ to a / : \"" + document.getElementById("4").href + "\"");
+                log("any other valid base except javascript: should convert a \\ to a / : \"" + document.getElementById("5").href + "\"");
+                log("query strings should be left alone: \"" + document.getElementById("6").href + "\"");
+                log("anchors should be left alone as well: \"" + document.getElementById("7").href + "\"");
+            }
+        </script>
+    </head>
+    <body onload="test()">
+        <p>This tests \ characters being changed to / in all different scenarios.</p>
+        <p>If it works you should see seven messages below that have \ or / characters as specified.</p>
+        <hr>
+        <a id="1" href="javascript:alert('to be\\not')">1</a>
+        <a id="2" href="http://apple.com\support">2</a>
+        <a id="3" href="https:\\login.apple.com\support/">3</a>
+        <a id="4" href="file:///Users\">4</a>
+        <a id="5" href="ftp://apple.com\support/">5</a>
+        <a id="6" href="http://apple.com\support?path=\\myshare\myfolder\myfile\">6</a>
+        <a id="7" href="http://apple.com\support#path=\\myshare\myfolder\myfile\">7</a>
+        <hr>
+        <p><ol id="console"></ol></p>
+    </body>
+</html>
index cccf854f7dfe0b3f641c41b26ce419e33d0775bb..17254f42003476a8a0ac209a5ce86c23e094f450 100644 (file)
@@ -1,3 +1,15 @@
+2006-09-11  Vladimir Olexa  <vladimir.olexa@gmail.com>
+
+        Reviewed by Darin.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=10323
+          REGRESSION: javascript: URL containing '\\' gets passed as '//'
+
+        Test: fast/dom/javascript-backslash.html
+
+        * platform/KURL.cpp: (WebCore::KURL::init): Don't do backslash
+        substitution in JavaScript URLs.
+
 2006-09-11  Sam Weinig  <sam.weinig@gmail.com>
 
         Reviewed by Darin and Tim H.
         Small cleanups + future plans
 
         * loader/icon/IconDatabase.cpp:
-        (WebCore::IconDatabase::open): path seperator cleanup
+        (WebCore::IconDatabase::open): path separator cleanup
         * platform/Image.h: 
      
 2006-09-10  Brady Eidson  <beidson@apple.com>
 2006-09-10  Brady Eidson  <beidson@apple.com>
 
         Forgetting header #define protection is BAAAAAD
-        (and re-alphabatized the project file)
+        (and re-alphabetized the project file)
 
         * WebCore.xcodeproj/project.pbxproj:
         * platform/IntSizeHash.h:
index ed60e33a49be1177e34e3cba783929b09fee84bf..590c79392eeff59681c3450cad5f19843158705b 100644 (file)
@@ -279,14 +279,14 @@ void KURL::init(const KURL &base, const DeprecatedString &relative, const TextEn
     
     bool absolute = false;
 
-    // for compatibility with Win IE, we must treat backslashes as if they were slashes
+    // for compatibility with Win IE, we must treat backslashes as if they were slashes, as long as we're not dealing with the javascript: schema
     DeprecatedString substitutedRelative;
-    bool containsBackslash = relative.contains('\\');
-    if (containsBackslash) {
+    bool shouldSubstituteBackslashes = relative.contains('\\') && !relative.startsWith("javascript:", false);
+    if (shouldSubstituteBackslashes) {
         substitutedRelative = substituteBackslashes(relative);
     }
 
-    const DeprecatedString &rel = containsBackslash ? substitutedRelative : relative;
+    const DeprecatedString &rel = shouldSubstituteBackslashes ? substitutedRelative : relative;
     
     bool allASCII = rel.isAllASCII();
     char *strBuffer;