From d220d1d461be5c47f5629c7ad66780df4376f632 Mon Sep 17 00:00:00 2001 From: "Misty (Bot)" Date: Wed, 25 Aug 2021 20:29:55 +0000 Subject: [PATCH 01/54] chore: incrementing version number - v1.18.0 --- install/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/package.json b/install/package.json index 0b9ee30661..c21d092815 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "1.17.2", + "version": "1.18.0", "homepage": "http://www.nodebb.org", "repository": { "type": "git", @@ -182,4 +182,4 @@ "url": "https://github.com/barisusakli" } ] -} +} \ No newline at end of file From 0409403f5b122fbf4221491cf3c81ff76fa0e4b1 Mon Sep 17 00:00:00 2001 From: "Misty (Bot)" Date: Fri, 3 Sep 2021 15:04:06 +0000 Subject: [PATCH 02/54] chore: incrementing version number - v1.18.1 --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 3e837e7f90..345e5e1add 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "1.18.0", + "version": "1.18.1", "homepage": "http://www.nodebb.org", "repository": { "type": "git", From 854c078b7385ce9f84850e09c8a6d8cd654aaca2 Mon Sep 17 00:00:00 2001 From: "Misty (Bot)" Date: Wed, 8 Sep 2021 16:27:00 +0000 Subject: [PATCH 03/54] chore: incrementing version number - v1.18.2 --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 1cb2211274..3f2f772b16 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "1.18.1", + "version": "1.18.2", "homepage": "http://www.nodebb.org", "repository": { "type": "git", From 9e52236973276dc4be837eb39e42193c547ba9f1 Mon Sep 17 00:00:00 2001 From: "Misty (Bot)" Date: Wed, 22 Sep 2021 17:01:44 +0000 Subject: [PATCH 04/54] chore: incrementing version number - v1.18.3 --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index b960000564..dd52eab1c9 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "1.18.2", + "version": "1.18.3", "homepage": "http://www.nodebb.org", "repository": { "type": "git", From 8593ea87e9b5d60eccd6e101d86b4f4e3a5ef4b3 Mon Sep 17 00:00:00 2001 From: "Misty (Bot)" Date: Wed, 6 Oct 2021 17:59:38 +0000 Subject: [PATCH 05/54] chore: incrementing version number - v1.18.4 --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 4a78966b57..17fb479da7 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "1.18.3", + "version": "1.18.4", "homepage": "http://www.nodebb.org", "repository": { "type": "git", From abbbc3d7c2c75a7877ee55debb9f47114e692778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 7 Oct 2021 09:16:53 -0400 Subject: [PATCH 06/54] chore: up persona --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 17fb479da7..b4445ae0f9 100644 --- a/install/package.json +++ b/install/package.json @@ -93,7 +93,7 @@ "nodebb-plugin-spam-be-gone": "0.7.9", "nodebb-rewards-essentials": "0.1.5", "nodebb-theme-lavender": "5.2.1", - "nodebb-theme-persona": "11.2.10", + "nodebb-theme-persona": "11.2.11", "nodebb-theme-slick": "1.4.13", "nodebb-theme-vanilla": "12.1.3", "nodebb-widget-essentials": "5.0.4", From c248805165a06d82be171f442278710064945f9f Mon Sep 17 00:00:00 2001 From: "Misty (Bot)" Date: Wed, 27 Oct 2021 16:47:58 +0000 Subject: [PATCH 07/54] chore: incrementing version number - v1.18.5 --- install/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/package.json b/install/package.json index 61ef2eece4..a4b1e1148d 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "1.18.4", + "version": "1.18.5", "homepage": "http://www.nodebb.org", "repository": { "type": "git", @@ -182,4 +182,4 @@ "url": "https://github.com/barisusakli" } ] -} +} \ No newline at end of file From ebe7f11d0b410d03bb2367945ec04f0924f453c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 27 Oct 2021 14:21:36 -0400 Subject: [PATCH 08/54] merge --- src/search.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/search.js b/src/search.js index 99fae633e8..0a0d1f459c 100644 --- a/src/search.js +++ b/src/search.js @@ -56,10 +56,19 @@ async function searchInContent(data) { } return []; } - const [pids, tids] = await Promise.all([ - doSearch('post', ['posts', 'titlesposts']), - doSearch('topic', ['titles', 'titlesposts']), - ]); + let pids = []; + let tids = []; + const inTopic = String(data.query || '').match(/^in:topic-([\d]+) /); + if (inTopic) { + const tid = inTopic[1]; + const cleanedTerm = data.query.replace(inTopic[0], ''); + pids = await topics.search(tid, cleanedTerm); + } else { + [pids, tids] = await Promise.all([ + doSearch('post', ['posts', 'titlesposts']), + doSearch('topic', ['titles', 'titlesposts']), + ]); + } if (data.returnIds) { return { pids: pids, tids: tids }; From 22e74dc0bb9cf296f548ad3b67ba1d297e4a7dc1 Mon Sep 17 00:00:00 2001 From: "Misty (Bot)" Date: Wed, 10 Nov 2021 20:45:24 +0000 Subject: [PATCH 09/54] chore: incrementing version number - v1.18.6 --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 22325d77db..b0b48b5c8f 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "1.18.5", + "version": "1.18.6", "homepage": "http://www.nodebb.org", "repository": { "type": "git", From 7ff2b7fbb1e296143bc8cdb9c136767507d1ffd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 16 Dec 2021 09:53:11 -0500 Subject: [PATCH 10/54] chore: up mentions to fix crash https://github.com/julianlam/nodebb-plugin-mentions/issues/156 --- install/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/package.json b/install/package.json index b0b48b5c8f..03667b6184 100644 --- a/install/package.json +++ b/install/package.json @@ -89,7 +89,7 @@ "nodebb-plugin-emoji": "^3.5.0", "nodebb-plugin-emoji-android": "2.0.5", "nodebb-plugin-markdown": "8.14.4", - "nodebb-plugin-mentions": "3.0.2", + "nodebb-plugin-mentions": "3.0.3", "nodebb-plugin-spam-be-gone": "0.7.11", "nodebb-rewards-essentials": "0.2.0", "nodebb-theme-lavender": "5.3.1", @@ -182,4 +182,4 @@ "url": "https://github.com/barisusakli" } ] -} \ No newline at end of file +} From edae9522b5535dc7e941edba22a2d2e81f58dae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 16 Dec 2021 09:54:09 -0500 Subject: [PATCH 11/54] feat: add data to filter:categories.search --- src/categories/search.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/categories/search.js b/src/categories/search.js index 5a19b9fab0..a4f079e2fd 100644 --- a/src/categories/search.js +++ b/src/categories/search.js @@ -18,6 +18,7 @@ module.exports = function (Categories) { let cids = await findCids(query, data.hardCap); const result = await plugins.hooks.fire('filter:categories.search', { + data: data, cids: cids, uid: uid, }); From 1f8f2e916892a5ad388b2eac76cfe761a7e4e5c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 16 Dec 2021 13:26:07 -0500 Subject: [PATCH 12/54] feat: pass in all query params to category search filter --- src/socket.io/categories/search.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/socket.io/categories/search.js b/src/socket.io/categories/search.js index 4d973a3f45..529ee136f4 100644 --- a/src/socket.io/categories/search.js +++ b/src/socket.io/categories/search.js @@ -50,12 +50,10 @@ module.exports = function (SocketCategories) { }; async function findMatchedCids(uid, data) { - const result = await categories.search({ - uid: uid, - query: data.search, - paginate: false, - }); - + const params = { ...data, uid, paginate: false }; + params.query = data.search; + params.qs = data.query; + const result = await categories.search(params); let matchedCids = result.categories.map(c => c.cid); // no need to filter if all 3 states are used From 1a375000a7eab014aaecb736c62872a874ad318f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 16 Dec 2021 13:46:49 -0500 Subject: [PATCH 13/54] refactor: only pass qs --- src/socket.io/categories/search.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/socket.io/categories/search.js b/src/socket.io/categories/search.js index 529ee136f4..ad04c20edf 100644 --- a/src/socket.io/categories/search.js +++ b/src/socket.io/categories/search.js @@ -50,10 +50,12 @@ module.exports = function (SocketCategories) { }; async function findMatchedCids(uid, data) { - const params = { ...data, uid, paginate: false }; - params.query = data.search; - params.qs = data.query; - const result = await categories.search(params); + const result = await categories.search({ + uid: uid, + query: data.search, + qs: data.query, + paginate: false, + }); let matchedCids = result.categories.map(c => c.cid); // no need to filter if all 3 states are used From b46dcd9243cafc2b087023345c0ceec51bb9d2ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 23 Dec 2021 11:05:37 -0500 Subject: [PATCH 14/54] fix: use component instead of class name --- public/src/client/topic/threadTools.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/src/client/topic/threadTools.js b/public/src/client/topic/threadTools.js index a393b00b1d..e627a51643 100644 --- a/public/src/client/topic/threadTools.js +++ b/public/src/client/topic/threadTools.js @@ -285,7 +285,7 @@ define('forum/topic/threadTools', [ threadEl.find('[component="post"][data-uid="' + app.user.uid + '"].deleted [component="post/tools"]').toggleClass('hidden', isLocked); - $('.topic-header [component="topic/locked"]').toggleClass('hidden', !data.isLocked); + $('[component="topic/labels"] [component="topic/locked"]').toggleClass('hidden', !data.isLocked); $('[component="post/tools"] .dropdown-menu').html(''); ajaxify.data.locked = data.isLocked; @@ -334,7 +334,7 @@ define('forum/topic/threadTools', [ components.get('topic/pin').toggleClass('hidden', data.pinned).parent().attr('hidden', data.pinned ? '' : null); components.get('topic/unpin').toggleClass('hidden', !data.pinned).parent().attr('hidden', !data.pinned ? '' : null); - const icon = $('.topic-header [component="topic/pinned"]'); + const icon = $('[component="topic/labels"] [component="topic/pinned"]'); icon.toggleClass('hidden', !data.pinned); if (data.pinned) { icon.translateAttr('title', ( From 00a6b05f8905c21725bcf16ce8bc5accf882d32f Mon Sep 17 00:00:00 2001 From: Opliko Date: Sun, 9 Jan 2022 01:26:28 +0100 Subject: [PATCH 15/54] Stop colors.js vandalism (#10131) * fix: pin colors to 1.4.0 * fix: exclude colors from renovate updates --- install/package.json | 2 +- renovate.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/install/package.json b/install/package.json index 03667b6184..1f8492be1d 100644 --- a/install/package.json +++ b/install/package.json @@ -41,7 +41,7 @@ "chart.js": "^2.9.4", "cli-graph": "^3.2.2", "clipboard": "^2.0.6", - "colors": "^1.4.0", + "colors": "1.4.0", "commander": "^7.1.0", "compare-versions": "3.6.0", "compression": "^1.7.4", diff --git a/renovate.json b/renovate.json index 78aef7647d..e880233256 100644 --- a/renovate.json +++ b/renovate.json @@ -6,7 +6,8 @@ "packageRules": [ { "updateTypes": ["minor", "patch", "pin", "digest"], - "automerge": true + "automerge": true, + "excludePackageNames": ["colors"] } ] } From aa77758afd7f97a762a7b53a910a72260153cfbe Mon Sep 17 00:00:00 2001 From: "Misty (Bot)" Date: Thu, 13 Jan 2022 18:51:21 +0000 Subject: [PATCH 16/54] chore: incrementing version number - v1.19.0 --- install/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/package.json b/install/package.json index 4b6be630f0..3de4a7f156 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "1.18.7", + "version": "1.19.0", "homepage": "http://www.nodebb.org", "repository": { "type": "git", @@ -183,4 +183,4 @@ "url": "https://github.com/barisusakli" } ] -} +} \ No newline at end of file From 7624af5769134524dee6fdb53db8107477ea4687 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 12 Nov 2021 14:58:02 -0500 Subject: [PATCH 17/54] feat: add feature flag to disable verification emails, closes #9996 --- install/data/defaults.json | 1 + .../language/en-GB/admin/settings/email.json | 3 ++- src/user/email.js | 7 +++++++ src/views/admin/settings/email.tpl | 21 ++++++++++++------- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/install/data/defaults.json b/install/data/defaults.json index 52b7683954..cd01e7644a 100644 --- a/install/data/defaults.json +++ b/install/data/defaults.json @@ -138,6 +138,7 @@ "disableEmailSubscriptions": 0, "emailConfirmInterval": 10, "removeEmailNotificationImages": 0, + "sendValidationEmail": 1, "includeUnverifiedEmails": 0, "emailPrompt": 1, "inviteExpiration": 7, diff --git a/public/language/en-GB/admin/settings/email.json b/public/language/en-GB/admin/settings/email.json index 65f579d28c..17c60daf69 100644 --- a/public/language/en-GB/admin/settings/email.json +++ b/public/language/en-GB/admin/settings/email.json @@ -38,7 +38,8 @@ "subscriptions.hour-help": "Please enter a number representing the hour to send scheduled email digests (e.g. 0 for midnight, 17 for 5:00pm). Keep in mind that this is the hour according to the server itself, and may not exactly match your system clock.
The approximate server time is:
The next daily digest is scheduled to be sent ", "notifications.remove-images": "Remove images from email notifications", "require-email-address": "Require new users to specify an email address", - "require-email-address-warning": "By default, users can opt-out of entering an email address. Enabling this option means they have to enter an email address in order to proceed with registration. It does not ensure user will enter a real email address, nor even an address they own.", + "require-email-address-warning": "By default, users can opt-out of entering an email address by leaving the field blank. Enabling this option means they have to enter an email address in order to proceed with registration. It does not ensure user will enter a real email address, nor even an address they own.", + "send-validation-email": "Send validation emails when an email is added or changed", "include-unverified-emails": "Send emails to recipients who have not explicitly confirmed their emails", "include-unverified-warning": "By default, users with emails associated with their account have already been verified, but there are situations where this is not the case (e.g. SSO logins, grandfathered users, etc). Enable this setting at your own risk – sending emails to unverified addresses may be a violation of regional anti-spam laws.", "prompt": "Prompt users to enter or confirm their emails", diff --git a/src/user/email.js b/src/user/email.js index d6d2d32b4d..a97aa1f38f 100644 --- a/src/user/email.js +++ b/src/user/email.js @@ -2,6 +2,7 @@ 'use strict'; const nconf = require('nconf'); +const winston = require('winston'); const user = require('./index'); const utils = require('../utils'); @@ -69,6 +70,11 @@ UserEmail.sendValidationEmail = async function (uid, options) { * - force, sends email even if it is too soon to send another */ + if (meta.config.sendValidationEmail !== 1) { + winston.verbose(`[user/email] Validation email for uid ${uid} not sent due to config settings`); + return; + } + options = options || {}; // Fallback behaviour (email passed in as second argument) @@ -110,6 +116,7 @@ UserEmail.sendValidationEmail = async function (uid, options) { await db.expireAt(`confirm:${confirm_code}`, Math.floor((Date.now() / 1000) + (60 * 60 * 24))); const username = await user.getUserField(uid, 'username'); + winston.verbose(`[user/email] Validation email for uid ${uid} sent to ${options.email}`); events.log({ type: 'email-confirmation-sent', uid, diff --git a/src/views/admin/settings/email.tpl b/src/views/admin/settings/email.tpl index 7f90431b96..e5b3fab134 100644 --- a/src/views/admin/settings/email.tpl +++ b/src/views/admin/settings/email.tpl @@ -20,13 +20,6 @@
-
- -
-

[[admin/settings/email:require-email-address-warning]]

+
+ +
+

[[admin/settings/email:prompt-help]]

+ +
+ +
From 04ce24e661a03136a6d71582a32cbca04da1ba2f Mon Sep 17 00:00:00 2001 From: "Misty (Bot)" Date: Fri, 21 Jan 2022 18:20:49 +0000 Subject: [PATCH 18/54] chore: incrementing version number - v1.19.1 --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index dc92e4a6fe..0a7faddce1 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "1.19.0", + "version": "1.19.1", "homepage": "http://www.nodebb.org", "repository": { "type": "git", From 04409632dda3bbd8da8bd0970f2dfb260b54c1a4 Mon Sep 17 00:00:00 2001 From: Lex Lim Date: Thu, 3 Feb 2022 07:45:53 +0000 Subject: [PATCH 19/54] =?UTF-8?q?=E4=BF=AE=E5=A4=8DSlug=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/category.js | 2 +- src/controllers/topics.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/category.js b/src/controllers/category.js index d233dbb369..3848f2f0e0 100644 --- a/src/controllers/category.js +++ b/src/controllers/category.js @@ -50,7 +50,7 @@ categoryController.get = async function (req, res, next) { return helpers.notAllowed(req, res); } - if (!res.locals.isAPI && !req.params.slug && (categoryFields.slug && categoryFields.slug !== `${cid}/`)) { + if (!res.locals.isAPI && !req.params.slug && (categoryFields.slug && categoryFields.slug !== `${cid}`)) { return helpers.redirect(res, `/category/${categoryFields.slug}?${qs.stringify(req.query)}`, true); } diff --git a/src/controllers/topics.js b/src/controllers/topics.js index 4f44a05344..1d3d0d48d2 100644 --- a/src/controllers/topics.js +++ b/src/controllers/topics.js @@ -58,7 +58,7 @@ topicsController.get = async function getTopic(req, res, callback) { return helpers.notAllowed(req, res); } - if (!res.locals.isAPI && (!req.params.slug || topicData.slug !== `${tid}/${req.params.slug}`) && (topicData.slug && topicData.slug !== `${tid}/`)) { + if (!res.locals.isAPI && (!req.params.slug || topicData.slug !== `${tid}/${req.params.slug}`) && (topicData.slug && topicData.slug !== `${tid}`)) { return helpers.redirect(res, `/topic/${topicData.slug}${postIndex ? `/${postIndex}` : ''}${generateQueryString(req.query)}`, true); } From 736db4745755736f059bcbc22dd7d29c546b059a Mon Sep 17 00:00:00 2001 From: Lex Lim Date: Thu, 3 Feb 2022 07:46:12 +0000 Subject: [PATCH 20/54] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/ajaxify.js | 48 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 26576dabbd..ec8b3fc1c6 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -10,6 +10,7 @@ ajaxify = window.ajaxify || {}; var retry = true; var previousBodyClass = ''; + ajaxify.loading = false; ajaxify.count = 0; ajaxify.currentPage = null; @@ -18,7 +19,26 @@ ajaxify = window.ajaxify || {}; hooks = _hooks; }); + var _throttleTimer = null; + var _cachedRequest = null; + function startThrottle(...args) { + if (typeof args[0] === "string") { + _cachedRequest = args; + } + if (_cachedRequest && !_throttleTimer) { + _throttleTimer = setTimeout(() => { + if (_cachedRequest) { + ajaxify.go.apply(ajaxify, _cachedRequest); + _cachedRequest = null; + } + _throttleTimer = null; + }, 500); + } + } + ajaxify.go = function (url, callback, quiet) { + ajaxify.loading = true; + // Automatically reconnect to socket and re-ajaxify on success if (!socket.connected) { app.reconnect(); @@ -35,11 +55,13 @@ ajaxify = window.ajaxify || {}; // Abort subsequent requests if clicked multiple times within a short window of time if (ajaxifyTimer && (Date.now() - ajaxifyTimer) < 500) { + startThrottle(url, callback, quiet); return true; } ajaxifyTimer = Date.now(); if (ajaxify.handleRedirects(url)) { + ajaxify.loading = false; return true; } @@ -60,6 +82,7 @@ ajaxify = window.ajaxify || {}; // If any listeners alter url and set it to an empty string, abort the ajaxification if (url === null) { hooks.fire('action:ajaxify.end', { url: url, tpl_url: ajaxify.data.template.name, title: ajaxify.data.title }); + ajaxify.loading = false; return false; } @@ -73,6 +96,7 @@ ajaxify = window.ajaxify || {}; (parseInt(err.data.status, 10) !== 302 && parseInt(err.data.status, 10) !== 308) )) { ajaxify.updateHistory(url, quiet); + ajaxify.loading = false; } if (err) { @@ -138,6 +162,8 @@ ajaxify = window.ajaxify || {}; var data = err.data; var textStatus = err.textStatus; + ajaxify.loading = false; + if (data) { var status = parseInt(data.status, 10); if (status === 403 || status === 404 || status === 500 || status === 502 || status === 503) { @@ -302,6 +328,18 @@ ajaxify = window.ajaxify || {}; hooks.fire('action:ajaxify.contentLoaded', { url: url, tpl: tpl_url }); app.processPage(); + + ajaxify.loading = false; + + if (_cachedRequest) { + if (_throttleTimer) { + clearTimeout(_throttleTimer); + _throttleTimer = null; + } + ajaxifyTimer = 0; + ajaxify.go(_cachedRequest[0], _cachedRequest[1], true); + _cachedRequest = null; + } }; ajaxify.parseData = function () { @@ -439,7 +477,7 @@ ajaxify = window.ajaxify || {}; }); }()); -$(document).ready(function () { +$(function () { var hooks; require(['hooks'], function (_hooks) { hooks = _hooks; @@ -490,8 +528,12 @@ $(document).ready(function () { // Special handling for urls with hashes if (window.location.pathname === this.pathname && this.hash.length) { window.location.hash = this.hash; - } else if (ajaxify.go(pathname)) { - e.preventDefault(); + } else { + var isReplaceLink = $this.parent('li').parent('.nav.nav-pills').length > 0 || + $this.parent('li').parent('.pagination').length > 0 + if (ajaxify.go(pathname, null, isReplaceLink)) { + e.preventDefault(); + } } } else if (window.location.pathname !== config.relative_path + '/outgoing') { if (config.openOutgoingLinksInNewTab && $.contains(contentEl, this)) { From 105501c7d92d9d2584011ee263a60303a0b7df79 Mon Sep 17 00:00:00 2001 From: Lex Lim Date: Thu, 3 Feb 2022 07:46:19 +0000 Subject: [PATCH 21/54] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B1=8F=E8=94=BD?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 515b93ce4a..569472301a 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,9 @@ provision.sh feeds/recent.rss .eslintcache .svn +cordova/ +plugins/ +config-* logs/ @@ -68,4 +71,8 @@ test/files/normalise-resized.jpg package-lock.json /package.json *.mongodb -link-plugins.sh \ No newline at end of file +link-plugins.sh + +# Isekai addition +makeCordova.sh +rebuild.sh From 522077ca50af03a37cc26c8d1cdf2852bc9bf93b Mon Sep 17 00:00:00 2001 From: Lex Lim Date: Mon, 7 Feb 2022 13:08:43 +0000 Subject: [PATCH 22/54] =?UTF-8?q?=E7=A7=BB=E9=99=A4realname=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/user/profile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/user/profile.js b/src/user/profile.js index 2748690b81..69c73eb729 100644 --- a/src/user/profile.js +++ b/src/user/profile.js @@ -178,13 +178,13 @@ module.exports = function (User) { } function isFullnameValid(data) { - if (data.fullname && (validator.isURL(data.fullname) || data.fullname.length > 255)) { + if (data.fullname && data.fullname.length > 255) { throw new Error('[[error:invalid-fullname]]'); } } function isLocationValid(data) { - if (data.location && (validator.isURL(data.location) || data.location.length > 255)) { + if (data.location && data.location.length > 255) { throw new Error('[[error:invalid-location]]'); } } From ded19254ace8515a7a9bc02d06f326f86b2ed6ee Mon Sep 17 00:00:00 2001 From: "Misty (Bot)" Date: Wed, 9 Feb 2022 21:28:32 +0000 Subject: [PATCH 23/54] chore: incrementing version number - v1.19.2 --- install/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install/package.json b/install/package.json index ff4aa39eb3..64bb5403f4 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "1.19.1", + "version": "1.19.2", "homepage": "http://www.nodebb.org", "repository": { "type": "git", @@ -109,7 +109,7 @@ "postcss": "8.4.6", "postcss-clean": "1.2.0", "prompt": "1.2.1", - "punycode": "2.1.1", + "punycode": "2.1.1", "ioredis": "4.28.5", "request": "2.88.2", "request-promise-native": "1.0.9", @@ -185,4 +185,4 @@ "url": "https://github.com/barisusakli" } ] -} +} \ No newline at end of file From 7388f111b78af34bf4918086285261db4a147cd1 Mon Sep 17 00:00:00 2001 From: "Misty (Bot)" Date: Wed, 16 Feb 2022 19:20:39 +0000 Subject: [PATCH 24/54] chore: incrementing version number - v1.19.3 --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 808b4e0c7b..df07065a1f 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "1.19.2", + "version": "1.19.3", "homepage": "http://www.nodebb.org", "repository": { "type": "git", From b60174f51ebf809786bf94cd0e2633e9825c933c Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 17 Feb 2022 12:30:03 -0500 Subject: [PATCH 25/54] fix: regression caused by 94b79ce4024f72a3eee2cfa06b05d8f66898149f `./nodebb setup` was no longer able to be called without arguments or env vars --- src/install.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/install.js b/src/install.js index f9f7912d9f..9afa1b54f9 100644 --- a/src/install.js +++ b/src/install.js @@ -47,7 +47,7 @@ questions.optional = [ ]; function checkSetupFlagEnv() { - let setupVal = install.values || {}; + let setupVal = install.values; const envConfMap = { NODEBB_URL: 'url', @@ -65,17 +65,21 @@ function checkSetupFlagEnv() { }; // Set setup values from env vars (if set) - winston.info('[install/checkSetupFlagEnv] checking env vars for setup info...'); - - Object.entries(process.env).forEach(([evName, evValue]) => { // get setup values from env - if (evName.startsWith('NODEBB_DB_')) { - setupVal[`${process.env.NODEBB_DB}:${envConfMap[evName]}`] = evValue; - } else if (evName.startsWith('NODEBB_')) { - setupVal[envConfMap[evName]] = evValue; - } - }); + const envKeys = Object.keys(process.env); + if (Object.keys(envConfMap).some(key => envKeys.includes(key))) { + winston.info('[install/checkSetupFlagEnv] checking env vars for setup info...'); + setupVal = setupVal || {}; + + Object.entries(process.env).forEach(([evName, evValue]) => { // get setup values from env + if (evName.startsWith('NODEBB_DB_')) { + setupVal[`${process.env.NODEBB_DB}:${envConfMap[evName]}`] = evValue; + } else if (evName.startsWith('NODEBB_')) { + setupVal[envConfMap[evName]] = evValue; + } + }); - setupVal['admin:password:confirm'] = setupVal['admin:password']; + setupVal['admin:password:confirm'] = setupVal['admin:password']; + } // try to get setup values from json, if successful this overwrites all values set by env // TODO: better behaviour would be to support overrides per value, i.e. in order of priority (generic pattern): From 3f13a69298531d77f62dcb76670d9fd0d5fe749f Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 17 Feb 2022 14:10:24 -0500 Subject: [PATCH 26/54] Re-introduce lodash into src/package-install.js (#10315) * test: add failing test for if package.json is non-existant, fix tests' beforeEach method * Revert "fix: #10289, remove lodash dependency in src/cli/package-install.js" This reverts commit 81fa2e22bc954a9c1878b0529cceee03f0f3a87b. * fix: regression caused by 94b79ce4024f72a3eee2cfa06b05d8f66898149f `./nodebb setup` was no longer able to be called without arguments or env vars * fix: .updatePackageFile() throwing if no package.json * fix: removing unneeded code in src/cli/index.js that seemed to be used to handle cases where package.json was missing (initial install) ... However, as .updatePackageFile() now handled cases where there is no package.json, it should be ok to remove this code * fix: handle missing package.json or node_modules/ --- src/cli/index.js | 33 +++++++++++---------------------- src/cli/package-install.js | 27 ++++++++------------------- test/package-install.js | 11 +++++++++-- 3 files changed, 28 insertions(+), 43 deletions(-) diff --git a/src/cli/index.js b/src/cli/index.js index 0ed6b449fd..7b5670dc75 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -10,31 +10,18 @@ require('../../require-main'); const packageInstall = require('./package-install'); const { paths } = require('../constants'); -// check to make sure dependencies are installed try { - fs.accessSync(paths.currentPackage, fs.constants.R_OK); -} catch (e) { - if (e.code === 'ENOENT') { - console.warn('package.json not found.'); - console.log('Populating package.json...'); - - packageInstall.updatePackageFile(); - packageInstall.preserveExtraneousPlugins(); - - try { - fs.accessSync(path.join(paths.nodeModules, 'chalk/package.json'), fs.constants.R_OK); - - const chalk = require('chalk'); - console.log(chalk.green('OK')); - } catch (e) { - console.log('OK'); + fs.accessSync(paths.currentPackage, fs.constants.R_OK); // throw on missing package.json + try { // handle missing node_modules/ directory + fs.accessSync(paths.nodeModules, fs.constants.R_OK); + } catch (e) { + if (e.code === 'ENOENT') { + // run package installation just to sync up node_modules/ with existing package.json + packageInstall.installAll(); + } else { + throw e; } - } else { - throw e; } -} - -try { fs.accessSync(path.join(paths.nodeModules, 'semver/package.json'), fs.constants.R_OK); const semver = require('semver'); @@ -53,12 +40,14 @@ try { checkVersion('async'); checkVersion('commander'); checkVersion('chalk'); + checkVersion('lodash'); } catch (e) { if (['ENOENT', 'DEP_WRONG_VERSION', 'MODULE_NOT_FOUND'].includes(e.code)) { console.warn('Dependencies outdated or not yet installed.'); console.log('Installing them now...\n'); packageInstall.updatePackageFile(); + packageInstall.preserveExtraneousPlugins(); packageInstall.installAll(); const chalk = require('chalk'); diff --git a/src/cli/package-install.js b/src/cli/package-install.js index d5e99b16d4..e9ca4a2e44 100644 --- a/src/cli/package-install.js +++ b/src/cli/package-install.js @@ -1,6 +1,7 @@ 'use strict'; const path = require('path'); + const fs = require('fs'); const cproc = require('child_process'); @@ -17,34 +18,22 @@ function sortDependencies(dependencies) { }, {}); } -function merge(to, from) { - // Poor man's version of _.merge() - if (Object.values(from).every(val => typeof val !== 'object')) { - return Object.assign(to, from); - } - - Object.keys(from).forEach((key) => { - if (Object.getPrototypeOf(from[key]) === Object.prototype) { - to[key] = merge(to[key], from[key]); - } else { - to[key] = from[key]; - } - }); - - return to; -} - pkgInstall.updatePackageFile = () => { - let oldPackageContents = {}; + let oldPackageContents; try { oldPackageContents = JSON.parse(fs.readFileSync(paths.currentPackage, 'utf8')); } catch (e) { if (e.code !== 'ENOENT') { throw e; + } else { + // No local package.json, copy from install/package.json + fs.copyFileSync(paths.installPackage, paths.currentPackage); + return; } } + const _ = require('lodash'); const defaultPackageContents = JSON.parse(fs.readFileSync(paths.installPackage, 'utf8')); let dependencies = {}; @@ -59,7 +48,7 @@ pkgInstall.updatePackageFile = () => { // Sort dependencies alphabetically dependencies = sortDependencies({ ...dependencies, ...defaultPackageContents.dependencies }); - const packageContents = { ...merge(oldPackageContents, defaultPackageContents), dependencies, devDependencies }; + const packageContents = { ..._.merge(oldPackageContents, defaultPackageContents), dependencies, devDependencies }; fs.writeFileSync(paths.currentPackage, JSON.stringify(packageContents, null, 4)); }; diff --git a/test/package-install.js b/test/package-install.js index 0d31387df1..97d6041bae 100644 --- a/test/package-install.js +++ b/test/package-install.js @@ -23,12 +23,11 @@ describe('Package install lib', () => { // Move `install/package.json` and `package.json` out of the way for now await fs.copyFile(sourcePackagePath, path.resolve(__dirname, '../install/package.json.bak')); // safekeeping await fs.copyFile(packageFilePath, path.resolve(__dirname, '../package.json.bak')); // safekeeping - await fs.copyFile(sourcePackagePath, packageFilePath); // match files for testing }); beforeEach(async () => { await fs.copyFile(path.resolve(__dirname, '../install/package.json.bak'), sourcePackagePath); - await fs.copyFile(path.resolve(__dirname, '../package.json.bak'), packageFilePath); + await fs.copyFile(sourcePackagePath, packageFilePath); // match files for testing source = JSON.parse(await fs.readFile(sourcePackagePath)); current = JSON.parse(await fs.readFile(packageFilePath)); }); @@ -95,6 +94,14 @@ describe('Package install lib', () => { assert.strictEqual(updated.devDependencies.hasOwnProperty('expect'), false); }); + it('should handle if there is no package.json', async () => { + await fs.unlink(packageFilePath); + + pkgInstall.updatePackageFile(); + const updated = JSON.parse(await fs.readFile(packageFilePath, 'utf8')); + assert.deepStrictEqual(updated, source); + }); + after(async () => { // Clean up await fs.rename(path.resolve(__dirname, '../install/package.json.bak'), sourcePackagePath); From 673fcfb052d7c76ccc506fd640d3a7030caafdc4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 18 Feb 2022 17:16:16 -0500 Subject: [PATCH 27/54] fix(deps): update dependency nodebb-plugin-mentions to v3.0.6 (#10328) Co-authored-by: Renovate Bot --- install/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/package.json b/install/package.json index df07065a1f..71f76d2cc4 100644 --- a/install/package.json +++ b/install/package.json @@ -90,8 +90,8 @@ "nodebb-plugin-dbsearch": "5.1.1", "nodebb-plugin-emoji": "3.5.16", "nodebb-plugin-emoji-android": "2.0.5", - "nodebb-plugin-markdown": "9.0.7", - "nodebb-plugin-mentions": "3.0.5", + "nodebb-plugin-markdown": "9.0.8", + "nodebb-plugin-mentions": "3.0.6", "nodebb-plugin-spam-be-gone": "0.7.13", "nodebb-rewards-essentials": "0.2.1", "nodebb-theme-lavender": "5.3.2", From d19a273ce9a016f3c164076ff399841a00b5d07b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 2 Mar 2022 11:08:16 -0500 Subject: [PATCH 28/54] fix: #10360, only take top level posts --- public/src/client/topic/posts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/client/topic/posts.js b/public/src/client/topic/posts.js index b84953e915..498604840a 100644 --- a/public/src/client/topic/posts.js +++ b/public/src/client/topic/posts.js @@ -132,7 +132,7 @@ define('forum/topic/posts', [ if (!isPreviousPostAdded && data.posts[0].selfPost) { return ajaxify.go('post/' + data.posts[0].pid); } - const repliesSelector = $('[component="post"]:not([data-index=0]), [component="topic/event"]'); + const repliesSelector = $('[component="topic"]>[component="post"]:not([data-index=0]), [component="topic"]>[component="topic/event"]'); createNewPosts(data, repliesSelector, direction, false, function (html) { if (html) { html.addClass('new'); From 4a87b3225c10096c9392e30bd30e47a4de398203 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 7 Mar 2022 18:20:19 +0000 Subject: [PATCH 29/54] fix(deps): update dependency nodebb-plugin-markdown to v9.0.10 --- install/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/package.json b/install/package.json index 71f76d2cc4..4cf9552783 100644 --- a/install/package.json +++ b/install/package.json @@ -90,7 +90,7 @@ "nodebb-plugin-dbsearch": "5.1.1", "nodebb-plugin-emoji": "3.5.16", "nodebb-plugin-emoji-android": "2.0.5", - "nodebb-plugin-markdown": "9.0.8", + "nodebb-plugin-markdown": "9.0.10", "nodebb-plugin-mentions": "3.0.6", "nodebb-plugin-spam-be-gone": "0.7.13", "nodebb-rewards-essentials": "0.2.1", @@ -184,4 +184,4 @@ "url": "https://github.com/barisusakli" } ] -} \ No newline at end of file +} From e4bd4f3107527070d709f0fb1f9515735648099e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 9 Mar 2022 15:07:36 -0500 Subject: [PATCH 30/54] feat: backport filter:posts.getUserInfoForPosts --- src/posts/user.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/posts/user.js b/src/posts/user.js index c92c197f69..e0964bc8c3 100644 --- a/src/posts/user.js +++ b/src/posts/user.js @@ -32,7 +32,7 @@ module.exports = function (Posts) { } }); - return await Promise.all(userData.map(async (userData) => { + const result = await Promise.all(userData.map(async (userData) => { const [isMemberOfGroups, signature, customProfileInfo] = await Promise.all([ checkGroupMembership(userData.uid, userData.groupTitleArray), parseSignature(userData, uid, uidsSignatureSet), @@ -51,6 +51,8 @@ module.exports = function (Posts) { return await plugins.hooks.fire('filter:posts.modifyUserInfo', userData); })); + const hookResult = await plugins.hooks.fire('filter:posts.getUserInfoForPosts', { users: result }); + return hookResult.users; }; Posts.overrideGuestHandle = function (postData, handle) { From 8d5ef172488423a875c429c922da57a29026eb11 Mon Sep 17 00:00:00 2001 From: "Misty (Bot)" Date: Wed, 9 Mar 2022 15:51:42 -0500 Subject: [PATCH 31/54] chore: incrementing version number - v1.19.4 (cherry picked from commit 67282057e7965ced445b0b0c0a1fd0142b2c751a) Signed-off-by: Misty (Bot) --- install/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/package.json b/install/package.json index 7902a85bc3..5d66d72ac7 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "1.19.3", + "version": "1.19.4", "homepage": "http://www.nodebb.org", "repository": { "type": "git", @@ -184,4 +184,4 @@ "url": "https://github.com/barisusakli" } ] -} +} \ No newline at end of file From a3ae8c48cea089f404d124a5c8adbf809a1d5204 Mon Sep 17 00:00:00 2001 From: "Misty (Bot)" Date: Wed, 16 Mar 2022 17:05:47 -0400 Subject: [PATCH 32/54] chore: incrementing version number - v1.19.5 (cherry picked from commit 48d6eb4f14ece17add920cfdb59a6f483efb3db1) Signed-off-by: Misty (Bot) --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 31ef65b796..bfc907e0fd 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "1.19.4", + "version": "1.19.5", "homepage": "http://www.nodebb.org", "repository": { "type": "git", From 35f0c559c09ebb2f4461905f73633eca9ec0fd78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 25 Feb 2022 18:42:45 -0500 Subject: [PATCH 33/54] fix: dont overwrite asset_base_url --- src/prestart.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/prestart.js b/src/prestart.js index 8f89336b9a..f2406e5ace 100644 --- a/src/prestart.js +++ b/src/prestart.js @@ -94,6 +94,9 @@ function loadConfig(configFile) { nconf.set('secure', urlObject.protocol === 'https:'); nconf.set('use_port', !!urlObject.port); nconf.set('relative_path', relativePath); + if (!nconf.get('asset_base_url')) { + nconf.set('asset_base_url', `${relativePath}/assets`); + } nconf.set('port', nconf.get('PORT') || nconf.get('port') || urlObject.port || (nconf.get('PORT_ENV_VAR') ? nconf.get(nconf.get('PORT_ENV_VAR')) : false) || 4567); // cookies don't provide isolation by port: http://stackoverflow.com/a/16328399/122353 From 37ba8a2c8ec078d00b450c65265c69906104cb3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 15 Feb 2022 19:22:34 -0500 Subject: [PATCH 34/54] fix: use asset_base_url --- public/src/ajaxify.js | 2 +- public/src/modules/translator.js | 2 +- src/controllers/api.js | 4 +++- test/mocks/databasemock.js | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index d42a0b89d1..a3cd09757b 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -424,7 +424,7 @@ ajaxify = window.ajaxify || {}; }; ajaxify.loadTemplate = function (template, callback) { - require([config.assetBaseUrl + '/templates/' + template + '.js'], callback, function (err) { + require([config.asset_base_url + '/templates/' + template + '.js'], callback, function (err) { console.error('Unable to load template: ' + template); throw err; }); diff --git a/public/src/modules/translator.js b/public/src/modules/translator.js index 00572536d5..eb40cf658f 100644 --- a/public/src/modules/translator.js +++ b/public/src/modules/translator.js @@ -3,7 +3,7 @@ (function (factory) { function loadClient(language, namespace) { return new Promise(function (resolve, reject) { - jQuery.getJSON([config.assetBaseUrl, 'language', language, namespace].join('/') + '.json?' + config['cache-buster'], function (data) { + jQuery.getJSON([config.asset_base_url, 'language', language, namespace].join('/') + '.json?' + config['cache-buster'], function (data) { const payload = { language: language, namespace: namespace, diff --git a/src/controllers/api.js b/src/controllers/api.js index 984ea98e42..3032fc80ff 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -14,6 +14,7 @@ const apiController = module.exports; const relative_path = nconf.get('relative_path'); const upload_url = nconf.get('upload_url'); +const asset_base_url = nconf.get('asset_base_url'); const socketioTransports = nconf.get('socket.io:transports') || ['polling', 'websocket']; const socketioOrigins = nconf.get('socket.io:origins'); const websocketAddress = nconf.get('socket.io:address') || ''; @@ -22,7 +23,8 @@ apiController.loadConfig = async function (req) { const config = { relative_path, upload_url, - assetBaseUrl: `${relative_path}/assets`, + asset_base_url, + assetBaseUrl: asset_base_url, // deprecate in 1.20.x siteTitle: validator.escape(String(meta.config.title || meta.config.browserTitle || 'NodeBB')), browserTitle: validator.escape(String(meta.config.browserTitle || meta.config.title || 'NodeBB')), titleLayout: (meta.config.titleLayout || '{pageTitle} | {browserTitle}').replace(/{/g, '{').replace(/}/g, '}'), diff --git a/test/mocks/databasemock.js b/test/mocks/databasemock.js index 911398b708..414cb7cfdd 100644 --- a/test/mocks/databasemock.js +++ b/test/mocks/databasemock.js @@ -38,6 +38,7 @@ nconf.defaults({ const urlObject = url.parse(nconf.get('url')); const relativePath = urlObject.pathname !== '/' ? urlObject.pathname : ''; nconf.set('relative_path', relativePath); +nconf.set('asset_base_url', `${relativePath}/assets`); nconf.set('upload_path', path.join(nconf.get('base_dir'), nconf.get('upload_path'))); nconf.set('upload_url', '/assets/uploads'); nconf.set('url_parsed', urlObject); From 32b38643f83338d329fe03dac16e88f2abfedffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 4 Apr 2022 17:34:52 -0400 Subject: [PATCH 35/54] feat: add response:helpers.notAllowed --- src/controllers/helpers.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/controllers/helpers.js b/src/controllers/helpers.js index 6b91bba943..e53edae33a 100644 --- a/src/controllers/helpers.js +++ b/src/controllers/helpers.js @@ -123,6 +123,11 @@ helpers.buildTerms = function (url, term, query) { helpers.notAllowed = async function (req, res, error) { ({ error } = await plugins.hooks.fire('filter:helpers.notAllowed', { req, res, error })); + await plugins.hooks.fire('response:helpers.notAllowed', { req, res, error }); + if (res.headersSent) { + return; + } + if (req.loggedIn || req.uid === -1) { if (res.locals.isAPI) { if (req.originalUrl.startsWith(`${relative_path}/api/v3`)) { From 24ba3e84cbad48d118f460eb49b687e3b848e1ee Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Wed, 13 Apr 2022 21:25:09 +0000 Subject: [PATCH 36/54] chore: incrementing version number - v1.19.6 (cherry picked from commit 283a0072a8ff9d2384a0beea308319b53dc9874f) Signed-off-by: Misty Release Bot --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index b287c6f43c..8d542d2c11 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "1.19.5", + "version": "1.19.6", "homepage": "http://www.nodebb.org", "repository": { "type": "git", From 804790017001c51af4d0e3ece74f2ad6b47e2eab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 21 Apr 2022 12:23:37 -0400 Subject: [PATCH 37/54] refactor: skip content length check if submitting from post-queue --- src/topics/create.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/topics/create.js b/src/topics/create.js index 1308827789..d62eb9800c 100644 --- a/src/topics/create.js +++ b/src/topics/create.js @@ -88,7 +88,9 @@ module.exports = function (Topics) { Topics.checkTitle(data.title); await Topics.validateTags(data.tags, data.cid, uid); data.tags = await Topics.filterTags(data.tags, data.cid); - Topics.checkContent(data.content); + if (!data.fromQueue) { + Topics.checkContent(data.content); + } const [categoryExists, canCreate, canTag] = await Promise.all([ categories.exists(data.cid), @@ -165,13 +167,13 @@ module.exports = function (Topics) { data.cid = topicData.cid; await guestHandleValid(data); - if (!data.fromQueue) { - await user.isReadyToPost(uid, data.cid); - } if (data.content) { data.content = utils.rtrim(data.content); } - Topics.checkContent(data.content); + if (!data.fromQueue) { + await user.isReadyToPost(uid, data.cid); + Topics.checkContent(data.content); + } // For replies to scheduled topics, don't have a timestamp older than topic's itself if (topicData.scheduled) { From bba9e7c0f735ccb15ce365d8dfa8b8becd0f4158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 22 Apr 2022 12:13:43 -0400 Subject: [PATCH 38/54] refactor: show invalid uri --- src/middleware/helpers.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/middleware/helpers.js b/src/middleware/helpers.js index bbf766895f..5c85989fc0 100644 --- a/src/middleware/helpers.js +++ b/src/middleware/helpers.js @@ -32,6 +32,7 @@ helpers.buildBodyClass = function (req, res, templateData = {}) { try { p = slugify(decodeURIComponent(p)); } catch (err) { + winston.error(`Error decoding URI: ${p}`); winston.error(err.stack); p = ''; } From e0080d90059b017ea86bcae97f6709e10a66883c Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Thu, 28 Apr 2022 13:40:04 +0000 Subject: [PATCH 39/54] chore: incrementing version number - v1.19.7 (cherry picked from commit 0c4850e2872b50716c1feb10a9363aa0935d7b57) Signed-off-by: Misty Release Bot --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 9efe296113..0848d671dd 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "1.19.6", + "version": "1.19.7", "homepage": "http://www.nodebb.org", "repository": { "type": "git", From 81e3c1ba488d03371a5ce8d0ebb5c5803026e0f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 26 May 2022 12:25:49 -0400 Subject: [PATCH 40/54] fix: get rid of math.random in generateUUID --- public/src/utils.js | 12 +++++------- src/utils.js | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/public/src/utils.js b/public/src/utils.js index 4eb2db22a4..64d58467a1 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -290,13 +290,11 @@ const utils = { generateUUID: function () { - /* eslint-disable no-bitwise */ - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { - const r = Math.random() * 16 | 0; - const v = c === 'x' ? r : ((r & 0x3) | 0x8); - return v.toString(16); - }); - /* eslint-enable no-bitwise */ + // from https://github.com/tracker1/node-uuid4/blob/master/browser.js + const temp_url = URL.createObjectURL(new Blob()); + const uuid = temp_url.toString(); + URL.revokeObjectURL(temp_url); + return uuid.split(/[:\/]/g).pop().toLowerCase(); // remove prefixes }, // https://github.com/substack/node-ent/blob/master/index.js decodeHTMLEntities: function (html) { diff --git a/src/utils.js b/src/utils.js index 8913909584..e122d798aa 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,3 +1,17 @@ 'use strict'; +const crypto = require('crypto'); + module.exports = require('../public/src/utils'); + +module.exports.generateUUID = function () { + // from https://github.com/tracker1/node-uuid4/blob/master/index.js + let rnd = crypto.randomBytes(16); + /* eslint-disable no-bitwise */ + rnd[6] = (rnd[6] & 0x0f) | 0x40; + rnd[8] = (rnd[8] & 0x3f) | 0x80; + /* eslint-enable no-bitwise */ + rnd = rnd.toString('hex').match(/(.{8})(.{4})(.{4})(.{4})(.{12})/); + rnd.shift(); + return rnd.join('-'); +}; \ No newline at end of file From 9bcd66e52e8f0d368024d86de22088bcd9b8222e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 17 Jun 2022 09:40:02 -0400 Subject: [PATCH 41/54] feat: cross origin opener policy options (#10710) --- install/data/defaults.json | 1 + public/language/en-GB/admin/settings/advanced.json | 1 + src/views/admin/settings/advanced.tpl | 9 +++++++++ src/webserver.js | 2 +- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/install/data/defaults.json b/install/data/defaults.json index fefa23b8ea..7fd51324c2 100644 --- a/install/data/defaults.json +++ b/install/data/defaults.json @@ -153,6 +153,7 @@ "digestHour": 17, "passwordExpiryDays": 0, "cross-origin-embedder-policy": 0, + "cross-origin-opener-policy": "same-origin", "cross-origin-resource-policy": "same-origin", "hsts-maxage": 31536000, "hsts-subdomains": 0, diff --git a/public/language/en-GB/admin/settings/advanced.json b/public/language/en-GB/admin/settings/advanced.json index ddf000be64..e372d48d70 100644 --- a/public/language/en-GB/admin/settings/advanced.json +++ b/public/language/en-GB/admin/settings/advanced.json @@ -17,6 +17,7 @@ "headers.acah": "Access-Control-Allow-Headers", "headers.coep": "Cross-Origin-Embedder-Policy", "headers.coep-help": "When enabled (default), will set the header to require-corp", + "headers.coop": "Cross-Origin-Opener-Policy", "headers.corp": "Cross-Origin-Resource-Policy", "hsts": "Strict Transport Security", "hsts.enabled": "Enabled HSTS (recommended)", diff --git a/src/views/admin/settings/advanced.tpl b/src/views/admin/settings/advanced.tpl index 6f997604e6..ae8f6e5c4d 100644 --- a/src/views/admin/settings/advanced.tpl +++ b/src/views/admin/settings/advanced.tpl @@ -73,6 +73,15 @@

[[admin/settings/advanced:headers.coep-help]]

+
+ + +
+