From b50bd5621a7885ea6b7a438c03edb882022e4476 Mon Sep 17 00:00:00 2001
From: Niko
Date: Mon, 21 Feb 2022 22:06:15 +0100
Subject: [PATCH] Fix pages.meet post html formatting
---
web/src/_templates/app/js.php | 1 +
web/src/app/js/app.js | 3 +++
web/src/app/js/base.js | 5 +++++
3 files changed, 9 insertions(+)
diff --git a/web/src/_templates/app/js.php b/web/src/_templates/app/js.php
index 859c43c..359cd9e 100644
--- a/web/src/_templates/app/js.php
+++ b/web/src/_templates/app/js.php
@@ -4,6 +4,7 @@ var env = {
dev: '' === '',
};
var app = {
+ domain: '',
strings: JSON.parse(atob('')),
pages: {},
hashHandlers: [],
diff --git a/web/src/app/js/app.js b/web/src/app/js/app.js
index 78d838f..cff243b 100644
--- a/web/src/app/js/app.js
+++ b/web/src/app/js/app.js
@@ -149,6 +149,7 @@ app.post = {
},
prepare4html: function(value, tags) {
tags = tags || [];
+ value = text2html(value);
value = value.replaceAll('', ' ')
.replaceAll(/\s+/g, ' ');
value = value.replaceAll('
', '{:br:}{:br:}');
@@ -166,6 +167,8 @@ app.post = {
continue;
acct = acct.trim().substr(1);
href = href.trim();
+ if (acct.endsWith(`@${app.domain}`))
+ acct = acct.replace(`@${app.domain}`, '');
const ps = acct.split('@');
const link = '@'+
htmlescape(acct) + '';
diff --git a/web/src/app/js/base.js b/web/src/app/js/base.js
index a4e1c0d..768c4b5 100644
--- a/web/src/app/js/base.js
+++ b/web/src/app/js/base.js
@@ -105,6 +105,11 @@ function isVisible(element) {
);
}
+function text2html(text) {
+ return text.replaceAll('>','>').replaceAll('<','<')
+ .replaceAll('"', '"').replaceAll('&', '&');
+}
+
function html2text(html) {
if (html === undefined || html === null)
return undefined;