зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
9d638b7341
Коммит
caed7f2e56
|
@ -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);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче