mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-03 11:01:20 +01:00
fix: #14001, regression from adjusted acceptable types list
This commit is contained in:
@@ -66,8 +66,15 @@ Helpers.isUri = (value) => {
|
||||
};
|
||||
|
||||
Helpers.assertAccept = (accept) => {
|
||||
if (!accept) return false;
|
||||
const normalized = accept.split(',').map(s => s.trim().replace(/\s*;\s*/g, ';')).join(',');
|
||||
if (!accept) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const normalized = accept
|
||||
.split(',')
|
||||
.map(s => s.trim().replace(/\s*;\s*/g, ';')) // spec allows spaces around semi-colon
|
||||
.join(',');
|
||||
|
||||
return activitypub._constants.acceptableTypes.some(type => normalized.includes(type));
|
||||
};
|
||||
|
||||
|
||||
@@ -19,11 +19,16 @@ middleware.pageview = async (req, res, next) => {
|
||||
middleware.assertS2S = async function (req, res, next) {
|
||||
// For whatever reason, express accepts does not recognize "profile" as a valid differentiator
|
||||
// Therefore, manual header parsing is used here.
|
||||
const { accept, 'content-type': contentType } = req.headers;
|
||||
let { accept, 'content-type': contentType } = req.headers;
|
||||
if (!(accept || contentType)) {
|
||||
return next('route');
|
||||
}
|
||||
|
||||
// Normalize content-type
|
||||
if (contentType) {
|
||||
contentType = contentType.trim().replace(/\s*;\s*/g, ';'); // spec allows spaces around semi-colon
|
||||
}
|
||||
|
||||
const pass = activitypub.helpers.assertAccept(accept) ||
|
||||
(contentType && activitypub._constants.acceptableTypes.includes(contentType));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user