зеркало из https://github.com/mozilla/pjs.git
Bug 430910 - nsStandardURL gets confused when the query string or the anchor name contains slash characters; r=bzbarsky a=roc
This commit is contained in:
Родитель
574ae25354
Коммит
16818d8ea0
|
@ -2005,13 +2005,13 @@ nsStandardURL::GetRelativeSpec(nsIURI *uri2, nsACString &aResult)
|
|||
while ((*(thatIndex-1) != '/') && (thatIndex != startCharPos))
|
||||
thatIndex--;
|
||||
|
||||
const char *limit = mSpec.get() + mFilepath.mPos + mFilepath.mLen;
|
||||
|
||||
// need to account for slashes and add corresponding "../"
|
||||
while (*thisIndex)
|
||||
for (; thisIndex <= limit && *thisIndex; ++thisIndex)
|
||||
{
|
||||
if (*thisIndex == '/')
|
||||
aResult.AppendLiteral("../");
|
||||
|
||||
thisIndex++;
|
||||
}
|
||||
|
||||
// grab spec from thisIndex to end
|
||||
|
|
|
@ -17,6 +17,24 @@ function run_test() {
|
|||
["http://foo.com/bar/", "http://foo.com:80/bar/", "" ],
|
||||
["http://foo.com/", "http://foo.com/a.htm#b", "a.htm#b" ],
|
||||
["http://foo.com/a/b/", "http://foo.com/c", "../../c" ],
|
||||
["http://foo.com/a?b/c/", "http://foo.com/c" , "c" ],
|
||||
["http://foo.com/a#b/c/", "http://foo.com/c" , "c" ],
|
||||
["http://foo.com/a;p?b/c/", "http://foo.com/c" , "c" ],
|
||||
["http://foo.com/a/b?c/d/", "http://foo.com/c", "../c" ],
|
||||
["http://foo.com/a/b#c/d/", "http://foo.com/c", "../c" ],
|
||||
["http://foo.com/a/b;p?c/d/", "http://foo.com/c", "../c" ],
|
||||
["http://foo.com/a/b/c?d/e/", "http://foo.com/f", "../../f" ],
|
||||
["http://foo.com/a/b/c#d/e/", "http://foo.com/f", "../../f" ],
|
||||
["http://foo.com/a/b/c;p?d/e/", "http://foo.com/f", "../../f" ],
|
||||
["http://foo.com/a?b/c/", "http://foo.com/c/d" , "c/d" ],
|
||||
["http://foo.com/a#b/c/", "http://foo.com/c/d" , "c/d" ],
|
||||
["http://foo.com/a;p?b/c/", "http://foo.com/c/d" , "c/d" ],
|
||||
["http://foo.com/a/b?c/d/", "http://foo.com/c/d", "../c/d" ],
|
||||
["http://foo.com/a/b#c/d/", "http://foo.com/c/d", "../c/d" ],
|
||||
["http://foo.com/a/b;p?c/d/", "http://foo.com/c/d", "../c/d" ],
|
||||
["http://foo.com/a/b/c?d/e/", "http://foo.com/f/g/", "../../f/g/" ],
|
||||
["http://foo.com/a/b/c#d/e/", "http://foo.com/f/g/", "../../f/g/" ],
|
||||
["http://foo.com/a/b/c;p?d/e/", "http://foo.com/f/g/", "../../f/g/" ],
|
||||
];
|
||||
|
||||
for (var i = 0; i < tests.length; i++) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче