]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't show referrer policy warning if fallback policy set. 19666/head
authorDaniel Kesselberg <mail@danielkesselberg.de>
Wed, 26 Feb 2020 22:14:38 +0000 (23:14 +0100)
committerDaniel Kesselberg <mail@danielkesselberg.de>
Wed, 26 Feb 2020 22:51:02 +0000 (23:51 +0100)
Test-Set:

no-referrer-when-downgrade
no-referrer
strict-origin-when-cross-origin
same-origin
no-referrer, strict-origin-when-cross-origin
strict-origin-
unsafe-raw, same-origin
strict-origin-when-downgrade

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
core/js/setupchecks.js

index 1e50644aa27f356673f55690aca8a029b121c421..95fb4f6b21348cdcb201976301301be10932cc76 100644 (file)
                                        });
                                }
 
-                               if (!xhr.getResponseHeader('Referrer-Policy') ||
-                                       (xhr.getResponseHeader('Referrer-Policy').toLowerCase() !== 'no-referrer' &&
-                                       xhr.getResponseHeader('Referrer-Policy').toLowerCase() !== 'no-referrer-when-downgrade' &&
-                                       xhr.getResponseHeader('Referrer-Policy').toLowerCase() !== 'strict-origin' &&
-                                       xhr.getResponseHeader('Referrer-Policy').toLowerCase() !== 'strict-origin-when-cross-origin' &&
-                                       xhr.getResponseHeader('Referrer-Policy').toLowerCase() !== 'same-origin')) {
+                               const referrerPolicy = xhr.getResponseHeader('Referrer-Policy')
+                               if (referrerPolicy === null || !/(no-referrer(-when-downgrade)?|strict-origin(-when-cross-origin)?|same-origin)(,|$)/.test(referrerPolicy)) {
                                        messages.push({
                                                msg: t('core', 'The "{header}" HTTP header is not set to "{val1}", "{val2}", "{val3}", "{val4}" or "{val5}". This can leak referer information. See the <a target="_blank" rel="noreferrer noopener" href="{link}">W3C Recommendation ↗</a>.',
                                                        {
                                                                link: 'https://www.w3.org/TR/referrer-policy/'
                                                        }),
                                                type: OC.SetupChecks.MESSAGE_TYPE_INFO
-                                       });
+                                       })
                                }
                        } else {
                                messages.push({