Skip to content

Node.js based forum software built for the modern web

feat: add minor pre-processing step to better handle header elements in incoming html

Julian Lam15f9fbaa5cec
diff --git a/install/package.json b/install/package.json
index 14e65fabd7..b2c185bacf 100644
--- a/install/package.json
+++ b/install/package.json
@@ -120,6 +120,7 @@
"pg-cursor": "2.15.3",
"postcss": "8.5.6",
"postcss-clean": "1.2.0",
+ "pretty": "^2.0.0",
"progress-webpack-plugin": "1.0.16",
"prompt": "1.3.0",
"redis": "5.8.2",
diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js
index 5739d25ecf..1671f8b1c6 100644
--- a/src/activitypub/notes.js
+++ b/src/activitypub/notes.js
@@ -3,6 +3,7 @@
const winston = require('winston');
const nconf = require('nconf');
const tokenizer = require('sbd');
+const pretty = require('pretty');
const db = require('../database');
const batch = require('../batch');
@@ -156,7 +157,8 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
// mainPid ok to leave as-is
if (!title) {
- const sentences = tokenizer.sentences(content || sourceContent, { sanitize: true, newline_boundaries: true });
+ const prettified = pretty(content || sourceContent);
+ const sentences = tokenizer.sentences(prettified, { sanitize: true, newline_boundaries: true });
title = sentences.shift();
}