Escape edit as plain text

This commit is contained in:
M66B 2020-03-02 16:50:17 +01:00
parent dd9f7d408a
commit 02d3803c4c
1 changed files with 4 additions and 1 deletions

View File

@ -870,8 +870,11 @@ public class FragmentCompose extends FragmentBase {
Document document = JsoupEx.parse(body); Document document = JsoupEx.parse(body);
if (plain) { if (plain) {
String text = HtmlHelper.getText(ref.outerHtml()); String text = HtmlHelper.getText(ref.outerHtml());
String[] line = text.split("\\r?\\n");
for (int i = 0; i < line.length; i++)
line[i] = Html.escapeHtml(line[i]);
Element p = document.createElement("p"); Element p = document.createElement("p");
p.html(text.replaceAll("\\r?\\n", "<br>")); p.html(TextUtils.join("<br>", line));
document.body().appendChild(p); document.body().appendChild(p);
} else { } else {
Document d = HtmlHelper.sanitize(context, ref.outerHtml(), true, false); Document d = HtmlHelper.sanitize(context, ref.outerHtml(), true, false);