summaryrefslogtreecommitdiffstats
path: root/dom/security
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 21:49:04 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 21:49:04 +0200
commit39dac57259cff8b61db0b22cb2ad0a8adb02692e (patch)
tree52a026cc8c22793eb17fd0f5e22adce1ae08a1dd /dom/security
parenta1cce3b2b00bbd9f4983013ddd8934a7bccb9e99 (diff)
parentc2d9ab62f3d097c9e0e00184cab1f546554f5eaa (diff)
downloadUXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar
UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.gz
UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.lz
UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.xz
UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.zip
Merge branch 'redwood' into 28.9-platform
Diffstat (limited to 'dom/security')
-rw-r--r--dom/security/nsCSPUtils.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/dom/security/nsCSPUtils.cpp b/dom/security/nsCSPUtils.cpp
index d07ad7945..6d4f297d6 100644
--- a/dom/security/nsCSPUtils.cpp
+++ b/dom/security/nsCSPUtils.cpp
@@ -555,7 +555,21 @@ permitsPort(const nsAString& aEnforcementScheme,
int32_t 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
// load if the resource to be loaded uses the default port for that