mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-05 03:51:26 +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) => {
|
Helpers.assertAccept = (accept) => {
|
||||||
if (!accept) return false;
|
if (!accept) {
|
||||||
const normalized = accept.split(',').map(s => s.trim().replace(/\s*;\s*/g, ';')).join(',');
|
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));
|
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) {
|
middleware.assertS2S = async function (req, res, next) {
|
||||||
// For whatever reason, express accepts does not recognize "profile" as a valid differentiator
|
// For whatever reason, express accepts does not recognize "profile" as a valid differentiator
|
||||||
// Therefore, manual header parsing is used here.
|
// Therefore, manual header parsing is used here.
|
||||||
const { accept, 'content-type': contentType } = req.headers;
|
let { accept, 'content-type': contentType } = req.headers;
|
||||||
if (!(accept || contentType)) {
|
if (!(accept || contentType)) {
|
||||||
return next('route');
|
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) ||
|
const pass = activitypub.helpers.assertAccept(accept) ||
|
||||||
(contentType && activitypub._constants.acceptableTypes.includes(contentType));
|
(contentType && activitypub._constants.acceptableTypes.includes(contentType));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user