mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 902375 - Strict file origin policy - handle case where the target is the parent directory of the source. r=bz
This commit is contained in:
parent
75c88795c6
commit
1d0b574237
@ -1976,19 +1976,26 @@ NS_RelaxStrictFileOriginPolicy(nsIURI *aTargetURI,
|
||||
// inherit its source principal and be scriptable by that source.
|
||||
//
|
||||
bool sourceIsDir;
|
||||
bool contained = false;
|
||||
bool allowed = false;
|
||||
nsresult rv = sourceFile->IsDirectory(&sourceIsDir);
|
||||
if (NS_SUCCEEDED(rv) && sourceIsDir) {
|
||||
rv = sourceFile->Contains(targetFile, true, &contained);
|
||||
rv = sourceFile->Contains(targetFile, true, &allowed);
|
||||
} else {
|
||||
nsCOMPtr<nsIFile> sourceParent;
|
||||
rv = sourceFile->GetParent(getter_AddRefs(sourceParent));
|
||||
if (NS_SUCCEEDED(rv) && sourceParent) {
|
||||
rv = sourceParent->Contains(targetFile, true, &contained);
|
||||
rv = sourceParent->Equals(targetFile, &allowed);
|
||||
if (NS_FAILED(rv) || !allowed) {
|
||||
rv = sourceParent->Contains(targetFile, true, &allowed);
|
||||
} else {
|
||||
MOZ_ASSERT(aAllowDirectoryTarget,
|
||||
"sourceFile->Parent == targetFile, but targetFile "
|
||||
"should've been disallowed if it is a directory");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && contained) {
|
||||
if (NS_SUCCEEDED(rv) && allowed) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user