diff --git a/netwerk/base/src/nsStandardURL.cpp b/netwerk/base/src/nsStandardURL.cpp index 45c69871b205..b7c12f4c3364 100644 --- a/netwerk/base/src/nsStandardURL.cpp +++ b/netwerk/base/src/nsStandardURL.cpp @@ -560,6 +560,11 @@ nsStandardURL::BuildNormalizedSpec(const char *spec) LOG(("adding leading slash to path\n")); leadingSlash = 1; buf[i++] = '/'; + // basename must exist, even if empty (bugs 113508, 429347) + if (mBasename.mLen == -1) { + mBasename.mPos = i; + mBasename.mLen = 0; + } } // record corrected (file)path starting position diff --git a/netwerk/test/unit/test_bug429347.js b/netwerk/test/unit/test_bug429347.js new file mode 100644 index 000000000000..166358149841 --- /dev/null +++ b/netwerk/test/unit/test_bug429347.js @@ -0,0 +1,36 @@ +const Cc = Components.classes; +const Ci = Components.interfaces; +const Cr = Components.results; + +function run_test() { + var ios = Cc["@mozilla.org/network/io-service;1"]. + getService(Ci.nsIIOService); + + var uri1 = ios.newURI("http://example.com#bar", null, null); + var uri2 = ios.newURI("http://example.com/#bar", null, null); + do_check_true(uri1.equals(uri2)); + + uri1.spec = "http://example.com?bar"; + uri2.spec = "http://example.com/?bar"; + do_check_true(uri1.equals(uri2)); + + uri1.spec = "http://example.com;bar"; + uri2.spec = "http://example.com/;bar"; + do_check_true(uri1.equals(uri2)); + + uri1.spec = "http://example.com#"; + uri2.spec = "http://example.com/#"; + do_check_true(uri1.equals(uri2)); + + uri1.spec = "http://example.com?"; + uri2.spec = "http://example.com/?"; + do_check_true(uri1.equals(uri2)); + + uri1.spec = "http://example.com;"; + uri2.spec = "http://example.com/;"; + do_check_true(uri1.equals(uri2)); + + uri1.spec = "http://example.com"; + uri2.spec = "http://example.com/"; + do_check_true(uri1.equals(uri2)); +} diff --git a/netwerk/test/unit/test_standardurl.js b/netwerk/test/unit/test_standardurl.js index 5d0ae21f06c4..2684d7342ba5 100644 --- a/netwerk/test/unit/test_standardurl.js +++ b/netwerk/test/unit/test_standardurl.js @@ -68,8 +68,7 @@ function test_setQuery() [ ["http://example.com", "http://example.com/?foo"], ["http://example.com/bar", "http://example.com/bar?foo"], - /* Can't test the path-less thing because of bug 429347 */ - /* ["http://example.com#bar", "http://example.com/?foo#bar"], */ + ["http://example.com#bar", "http://example.com/?foo#bar"], ["http://example.com/#bar", "http://example.com/?foo#bar"], ["http://example.com/?longerthanfoo#bar", "http://example.com/?foo#bar"], ["http://example.com/?longerthanfoo", "http://example.com/?foo"],