Bug 429347 - "URL parser gets confused by ref with no path" [r=bzbarsky sr=cbiesinger]

This commit is contained in:
Michal Novotny 2008-10-01 00:34:29 -05:00
Родитель 294525a204
Коммит c6c4687357
3 изменённых файлов: 42 добавлений и 2 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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));
}

Просмотреть файл

@ -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"],