mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-25 00:27:29 +09:00
[CSP] Allow not having a Port for RessourceURI if the Scheme has no
Default Port
This commit is contained in:
parent
71bc312d95
commit
2537698cd2
1 changed files with 15 additions and 1 deletions
|
|
@ -555,7 +555,21 @@ permitsPort(const nsAString& aEnforcementScheme,
|
||||||
|
|
||||||
int32_t resourcePort;
|
int32_t resourcePort;
|
||||||
nsresult rv = aResourceURI->GetPort(&resourcePort);
|
nsresult rv = aResourceURI->GetPort(&resourcePort);
|
||||||
NS_ENSURE_SUCCESS(rv, false);
|
if (NS_FAILED(rv) && aEnforcementPort.IsEmpty()) {
|
||||||
|
// If we cannot get a Port (e.g. because of an Custom Protocol handler)
|
||||||
|
// we need to check if a default port is associated with the Scheme
|
||||||
|
if (aEnforcementScheme.IsEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int defaultPortforScheme =
|
||||||
|
NS_GetDefaultPort(NS_ConvertUTF16toUTF8(aEnforcementScheme).get());
|
||||||
|
|
||||||
|
// If there is no default port associated with the Scheme (
|
||||||
|
// defaultPortforScheme == -1) or it is an externally handled protocol (
|
||||||
|
// defaultPortforScheme == 0 ) and the csp does not enforce a port - we can
|
||||||
|
// allow not having a port
|
||||||
|
return (defaultPortforScheme == -1 || defaultPortforScheme == 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Avoid unnecessary string creation/manipulation and don't block the
|
// Avoid unnecessary string creation/manipulation and don't block the
|
||||||
// load if the resource to be loaded uses the default port for that
|
// load if the resource to be loaded uses the default port for that
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue