Skip to content

Node.js based forum software built for the modern web

breaking: core html stripping on plaintext, remove 'filter:teasers.configureStripTags' hook, remove html stripping from teaser generation

Julian Lamc01f15493708
diff --git a/install/package.json b/install/package.json
index a1bc10edc7..5f0a62cda6 100644
--- a/install/package.json
+++ b/install/package.json
@@ -100,7 +100,7 @@
"nodebb-plugin-dbsearch": "6.2.5",
"nodebb-plugin-emoji": "5.1.15",
"nodebb-plugin-emoji-android": "4.0.0",
- "nodebb-plugin-markdown": "13.0.0-pre.8",
+ "nodebb-plugin-markdown": "13.0.0-pre.9",
"nodebb-plugin-mentions": "4.6.7",
"nodebb-plugin-ntfy": "1.7.4",
"nodebb-plugin-spam-be-gone": "2.2.2",
diff --git a/src/posts/parse.js b/src/posts/parse.js
index 25e14cc3fc..add64ac4d7 100644
--- a/src/posts/parse.js
+++ b/src/posts/parse.js
@@ -126,6 +126,10 @@ module.exports = function (Posts) {
});
};
+ Posts.sanitizePlaintext = content => sanitize(content, {
+ allowedTags: [],
+ });
+
Posts.configureSanitize = async () => {
// Each allowed tags should have some common global attributes...
sanitizeConfig.allowedTags.forEach((tag) => {
@@ -143,7 +147,7 @@ module.exports = function (Posts) {
plugins.hooks.register('core', {
hook: 'filter:parse.post',
method: async (data) => {
- data.postData.content = Posts.sanitize(data.postData.content);
+ data.postData.content = Posts[data.type !== 'plaintext' ? 'sanitize' : 'sanitizePlaintext'](data.postData.content);
return data;
},
});
diff --git a/src/topics/teaser.js b/src/topics/teaser.js
index 3e091b03da..1b8f8f3d37 100644
--- a/src/topics/teaser.js
+++ b/src/topics/teaser.js
@@ -70,19 +70,12 @@ module.exports = function (Topics) {
});
await Promise.all(postData.map(p => posts.parsePost(p, 'plaintext')));
- const { tags } = await plugins.hooks.fire('filter:teasers.configureStripTags', {
- tags: utils.stripTags.slice(0),
- });
-
const teasers = topics.map((topic, index) => {
if (!topic) {
return null;
}
if (tidToPost[topic.tid]) {
tidToPost[topic.tid].index = calcTeaserIndex(teaserPost, counts[index], sortNewToOld);
- if (tidToPost[topic.tid].content) {
- tidToPost[topic.tid].content = utils.stripHTMLTags(replaceImgWithAltText(tidToPost[topic.tid].content), tags);
- }
}
return tidToPost[topic.tid];
});