mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1277583, r=bz
MozReview-Commit-ID: E9gNZAOQzG9 --HG-- extra : rebase_source : 302534c6ef5c064c3956188dd52fcf668db0d0e1 extra : histedit_source : c97f8279ebeea7b9a6c93d88f6809c38cac2ee14
This commit is contained in:
parent
c9ca48ffa9
commit
4d279191b4
@ -674,37 +674,32 @@ EqualOrSubdomain(nsIURI* aProbeArg, nsIURI* aBase)
|
||||
static bool
|
||||
AllSchemesMatch(nsIURI* aURI, nsIURI* aOtherURI)
|
||||
{
|
||||
nsCOMPtr<nsINestedURI> nestedURI = do_QueryInterface(aURI);
|
||||
nsCOMPtr<nsINestedURI> nestedOtherURI = do_QueryInterface(aOtherURI);
|
||||
auto stringComparator = nsCaseInsensitiveCStringComparator();
|
||||
if (!nestedURI && !nestedOtherURI) {
|
||||
// Neither of the URIs is nested, compare their schemes directly:
|
||||
nsAutoCString scheme, otherScheme;
|
||||
aURI->GetScheme(scheme);
|
||||
aOtherURI->GetScheme(otherScheme);
|
||||
return scheme.Equals(otherScheme, stringComparator);
|
||||
}
|
||||
while (nestedURI && nestedOtherURI) {
|
||||
nsCOMPtr<nsIURI> currentURI = do_QueryInterface(nestedURI);
|
||||
nsCOMPtr<nsIURI> currentOtherURI = do_QueryInterface(nestedOtherURI);
|
||||
nsCOMPtr<nsIURI> currentURI = aURI;
|
||||
nsCOMPtr<nsIURI> currentOtherURI = aOtherURI;
|
||||
while (currentURI && currentOtherURI) {
|
||||
nsAutoCString scheme, otherScheme;
|
||||
currentURI->GetScheme(scheme);
|
||||
currentOtherURI->GetScheme(otherScheme);
|
||||
if (!scheme.Equals(otherScheme, stringComparator)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINestedURI> nestedURI = do_QueryInterface(currentURI);
|
||||
nsCOMPtr<nsINestedURI> nestedOtherURI = do_QueryInterface(currentOtherURI);
|
||||
// If neither are nested and all schemes have matched so far
|
||||
// (or we would have bailed already), we're the same:
|
||||
if (!nestedURI && !nestedOtherURI) {
|
||||
return true;
|
||||
}
|
||||
// If one is nested and the other not, they're not equal:
|
||||
if (!nestedURI != !nestedOtherURI) {
|
||||
return false;
|
||||
}
|
||||
// At this stage, both are still nested URIs, so let's play again:
|
||||
nestedURI->GetInnerURI(getter_AddRefs(currentURI));
|
||||
nestedOtherURI->GetInnerURI(getter_AddRefs(currentOtherURI));
|
||||
nestedURI = do_QueryInterface(currentURI);
|
||||
nestedOtherURI = do_QueryInterface(currentOtherURI);
|
||||
}
|
||||
if (!!nestedURI != !!nestedOtherURI) {
|
||||
// If only one of the scheme chains runs out at one point, clearly the chains
|
||||
// aren't of the same length, so we bail:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
Loading…
Reference in New Issue
Block a user