mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: inability for plugins to actually alter parser sanitization config
/cc @pitaj
This commit is contained in:
@@ -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 = [];
|
||||
|
||||
Reference in New Issue
Block a user