Skip to content

Commit 9522ef8

Browse files
authored
Merge pull request #43778 from nextcloud/fix/edge-csp
Fix CSP for script-src with nonce on edge
2 parents 1c0191a + 78ba1b0 commit 9522ef8

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

lib/private/AppFramework/Http/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
class Request implements \ArrayAccess, \Countable, IRequest {
6969
public const USER_AGENT_IE = '/(MSIE)|(Trident)/';
7070
// Microsoft Edge User Agent from https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
71-
public const USER_AGENT_MS_EDGE = '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Chrome\/[0-9.]+ (Mobile Safari|Safari)\/[0-9.]+ Edge\/[0-9.]+$/';
71+
public const USER_AGENT_MS_EDGE = '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Chrome\/[0-9.]+ (Mobile Safari|Safari)\/[0-9.]+ Edge?\/[0-9.]+$/';
7272
// Firefox User Agent from https://developer.mozilla.org/en-US/docs/Web/HTTP/Gecko_user_agent_string_reference
7373
public const USER_AGENT_FIREFOX = '/^Mozilla\/5\.0 \([^)]+\) Gecko\/[0-9.]+ Firefox\/[0-9.]+$/';
7474
// Chrome User Agent from https://developer.chrome.com/multidevice/user-agent

lib/private/Security/CSP/ContentSecurityPolicyNonceManager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public function browserSupportsCspV3(): bool {
6969
Request::USER_AGENT_CHROME,
7070
Request::USER_AGENT_FIREFOX,
7171
Request::USER_AGENT_SAFARI,
72+
Request::USER_AGENT_MS_EDGE,
7273
];
7374

7475
if ($this->request->isUserAgent($browserWhitelist)) {

lib/public/AppFramework/Http/EmptyContentSecurityPolicy.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
* @since 9.0.0
3838
*/
3939
class EmptyContentSecurityPolicy {
40-
/** @var string JS nonce to be used */
41-
protected $jsNonce = null;
40+
/** @var ?string JS nonce to be used */
41+
protected ?string $jsNonce = null;
4242
/** @var bool Whether strict-dynamic should be used */
4343
protected $strictDynamicAllowed = null;
4444
/** @var bool Whether strict-dynamic should be used on script-src-elem */
@@ -460,7 +460,7 @@ public function buildPolicy() {
460460
$policy .= "base-uri 'none';";
461461
$policy .= "manifest-src 'self';";
462462

463-
if (!empty($this->allowedScriptDomains) || $this->evalScriptAllowed || $this->evalWasmAllowed) {
463+
if (!empty($this->allowedScriptDomains) || $this->evalScriptAllowed || $this->evalWasmAllowed || is_string($this->jsNonce)) {
464464
$policy .= 'script-src ';
465465
$scriptSrc = '';
466466
if (is_string($this->jsNonce)) {

0 commit comments

Comments
 (0)