fix bug 163225 [success or failure of ExtractScheme is not enough to

decide if a url is absolute or relative] This is second part of the
stuff to support those deprecated relative urls of type http:file or
http:/path. By loosening the check on absolute uris in
nsIOService::NewURI nsStandardURL::Resolve gets a chance to do its job.
r=bbaetz, sr=darin
This commit is contained in:
andreas.otte%debitel.net 2002-08-29 21:31:55 +00:00
Родитель 9d638b7341
Коммит caed7f2e56
2 изменённых файлов: 17 добавлений и 5 удалений

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

@ -727,11 +727,7 @@ nsIOService::NewURI(const nsACString &aSpec, const char *aCharset, nsIURI *aBase
nsCAutoString scheme;
rv = ExtractScheme(aSpec, scheme);
if (NS_SUCCEEDED(rv)) {
// then aSpec is absolute... ignore aBaseURI in this case
aBaseURI = nsnull;
}
else {
if (NS_FAILED(rv)) {
// then aSpec is relative
if (!aBaseURI)
return NS_ERROR_MALFORMED_URI;

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

@ -2306,6 +2306,22 @@ nsStandardURL::Init(PRUint32 urlType,
return NS_OK;
}
if (baseURI) {
PRUint32 start, end;
// pull out the scheme and where it ends
nsresult rv = ExtractURLScheme(spec, &start, &end, nsnull);
if (NS_SUCCEEDED(rv) && spec.Length() > end+1) {
nsACString::const_iterator slash;
spec.BeginReading(slash);
slash.advance(end);
// then check if // follows
// if it follows, aSpec is really absolute ...
// ignore aBaseURI in this case
if (*slash == '/' && *(++slash) == '/')
baseURI = nsnull;
}
}
if (!baseURI)
return SetSpec(spec);