Node.js based forum software built for the modern web
fix: don't count internal links towards link count when restricting new users from posting links
Julian Lam022fa0e75f48
diff --git a/src/posts/queue.js b/src/posts/queue.jsindex 8d6550b7fd..23419d2ee3 100644--- a/src/posts/queue.js+++ b/src/posts/queue.js@@ -96,9 +96,16 @@ module.exports = function (Posts) {if (!isPrivileged && reputation < meta.config['min:rep:post-links']) {const parsed = await plugins.hooks.fire('filter:parse.raw', String(content));- if (parsed.match(/<a[^>]*>([^<]+)<\/a>/g)) {- return false;+ const matches = parsed.matchAll(/<a[^>]*href="([^"]+)"[^>]*>/g);+ let external = 0;+ for (const [, href] of matches) {+ const internal = utils.isInternalURI(new URL(href, nconf.get('url')), new URL(nconf.get('url')), nconf.get('relative_path'));+ if (!internal) {+ external += 1;+ }}++ return external === 0;}return true;};