diff --git a/src/plugins/index.js b/src/plugins/index.js index c3c322d429..387933290f 100644 --- a/src/plugins/index.js +++ b/src/plugins/index.js @@ -155,6 +155,9 @@ Plugins.reload = async function () { Object.keys(Plugins.loadedHooks).forEach(function (hook) { Plugins.loadedHooks[hook].sort((a, b) => a.priority - b.priority); }); + + // Post-reload actions + await posts.configureSanitize(); }; Plugins.reloadRoutes = async function (params) { diff --git a/src/posts/parse.js b/src/posts/parse.js index 652287bd6a..f4c110623f 100644 --- a/src/posts/parse.js +++ b/src/posts/parse.js @@ -35,16 +35,6 @@ let sanitizeConfig = { ], }; -process.nextTick(async () => { - // Each allowed tags should have some common global attributes... - sanitizeConfig.allowedTags.forEach((tag) => { - sanitizeConfig.allowedAttributes[tag] = _.union(sanitizeConfig.allowedAttributes[tag], sanitizeConfig.globalAttributes); - }); - - // Some plugins might need to adjust or whitelist their own tags... - sanitizeConfig = await plugins.fireHook('filter:sanitize.config', sanitizeConfig); -}); - module.exports = function (Posts) { Posts.urlRegex = { regex: /href="([^"]+)"/g, @@ -119,6 +109,15 @@ module.exports = function (Posts) { }); }; + Posts.configureSanitize = async () => { + // Each allowed tags should have some common global attributes... + sanitizeConfig.allowedTags.forEach((tag) => { + sanitizeConfig.allowedAttributes[tag] = _.union(sanitizeConfig.allowedAttributes[tag], sanitizeConfig.globalAttributes); + }); + + sanitizeConfig = await plugins.fireHook('filter:sanitize.config', sanitizeConfig); + }; + function sanitizeSignature(signature) { signature = translator.escape(signature); var tagsToStrip = [];