Node.js based forum software built for the modern web
fix: closes #13199 normalize accept header
Barış Soner Uşaklıec4e7ef1b7b0
diff --git a/src/activitypub/helpers.js b/src/activitypub/helpers.jsindex 80135808ab..a966d26ac0 100644--- a/src/activitypub/helpers.js+++ b/src/activitypub/helpers.js@@ -65,10 +65,11 @@ Helpers.isUri = (value) => {});};-Helpers.assertAccept = accept => (accept && accept.split(',').some((value) => {- const parts = value.split(';').map(v => v.trim());- return activitypub._constants.acceptableTypes.includes(value || parts[0]);-}));+Helpers.assertAccept = (accept) => {+ if (!accept) return false;+ const normalized = accept.split(',').map(s => s.trim().replace(/\s*;\s*/g, ';')).join(',');+ return activitypub._constants.acceptableTypes.some(type => normalized.includes(type));+};Helpers.isWebfinger = (value) => {// N.B. returns normalized handle, so truthy check!diff --git a/src/activitypub/index.js b/src/activitypub/index.jsindex 92dd10b544..4ab6159f2f 100644--- a/src/activitypub/index.js+++ b/src/activitypub/index.js@@ -41,7 +41,7 @@ ActivityPub._constants = Object.freeze({acceptablePublicAddresses: ['https://www.w3.org/ns/activitystreams#Public', 'as:Public', 'Public'],acceptableTypes: ['application/activity+json',- 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',+ 'application/ld+json;profile="https://www.w3.org/ns/activitystreams"',],acceptedPostTypes: ['Note', 'Page', 'Article', 'Question', 'Video',