});
}
- 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({