Merge pull request #19666 from nextcloud/bug/19416/referrer-policy-fallback

Don't show referrer policy warning if fallback policy set.
This commit is contained in:
Roeland Jago Douma 2020-02-28 09:46:09 +01:00 committed by GitHub
commit dd5a4c9603
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 7 deletions

View File

@ -573,12 +573,8 @@
}); });
} }
if (!xhr.getResponseHeader('Referrer-Policy') || const referrerPolicy = xhr.getResponseHeader('Referrer-Policy')
(xhr.getResponseHeader('Referrer-Policy').toLowerCase() !== 'no-referrer' && if (referrerPolicy === null || !/(no-referrer(-when-downgrade)?|strict-origin(-when-cross-origin)?|same-origin)(,|$)/.test(referrerPolicy)) {
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')) {
messages.push({ 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>.', 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>.',
{ {
@ -591,7 +587,7 @@
link: 'https://www.w3.org/TR/referrer-policy/' link: 'https://www.w3.org/TR/referrer-policy/'
}), }),
type: OC.SetupChecks.MESSAGE_TYPE_INFO type: OC.SetupChecks.MESSAGE_TYPE_INFO
}); })
} }
} else { } else {
messages.push({ messages.push({