Node.js based forum software built for the modern web
fix: better logic for choosing webfinger lookups
Oplikoed84eed8a9ce
diff --git a/src/activitypub/actors.js b/src/activitypub/actors.jsindex 73dead4c9b..a581c9081e 100644--- a/src/activitypub/actors.js+++ b/src/activitypub/actors.js@@ -31,8 +31,9 @@ Actors.assert = async (ids, options = {}) => {// Translate webfinger handles to urisids = (await Promise.all(ids.map(async (id) => {const originalId = id;- if (id.includes('@')) {- const isUri = activitypub.helpers.isUri(id);+ const isUri = activitypub.helpers.isUri(id);+ // only look up webfinger if the id is not a supported URI+ if (id.includes('@') && !(isUri && activitypub._constants.acceptedProtocols.includes(new URL(id).protocol.slice(0, -1)))) {const host = isUri ? new URL(id).host : id.split('@')[1];if (host === nconf.get('url_parsed').host) { // do not assert loopback idsreturn null;diff --git a/src/activitypub/helpers.js b/src/activitypub/helpers.jsindex 24c61cade8..45fc36bfa9 100644--- a/src/activitypub/helpers.js+++ b/src/activitypub/helpers.js@@ -22,15 +22,10 @@ Helpers.isUri = (value) => {value = String(value);}- const protocols = ['https'];- if (process.env.CI === 'true') {- protocols.push('http');- }-return validator.isURL(value, {require_protocol: true,require_host: true,- protocols,+ protocols: activitypub._constants.acceptedProtocols,require_valid_protocol: true,require_tld: false, // temporary — for localhost});diff --git a/src/activitypub/index.js b/src/activitypub/index.jsindex 94460c6d52..357de15f9f 100644--- a/src/activitypub/index.js+++ b/src/activitypub/index.js@@ -24,6 +24,7 @@ ActivityPub._constants = Object.freeze({acceptedPostTypes: ['Note', 'Page', 'Article', 'Question',],+ acceptedProtocols: ['https', ...(process.env.CI === 'true' ? ['http'] : [])],});ActivityPub._cache = requestCache;