mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-06 17:13:23 +02:00
Simplified newline handling
This commit is contained in:
@@ -289,7 +289,7 @@ public class HtmlHelper {
|
||||
|
||||
static Document sanitizeCompose(Context context, String html, boolean show_images) {
|
||||
try {
|
||||
Document parsed = fixEdit(JsoupEx.parse(html));
|
||||
Document parsed = JsoupEx.parse(html);
|
||||
return sanitize(context, parsed, false, show_images);
|
||||
} catch (Throwable ex) {
|
||||
// OutOfMemoryError
|
||||
@@ -302,22 +302,6 @@ public class HtmlHelper {
|
||||
}
|
||||
}
|
||||
|
||||
static Document fixEdit(Document document) {
|
||||
// Prevent extra newline at end
|
||||
Element body = document.body();
|
||||
if (body != null && body.childrenSize() > 0) {
|
||||
Element holder = body.child(body.childrenSize() - 1);
|
||||
if ("p".equals(holder.tagName())) {
|
||||
holder.tagName("span");
|
||||
int c = holder.childNodeSize();
|
||||
Node last = (c > 0 ? holder.childNode(c - 1) : null);
|
||||
if (last == null || !"br".equals(last.nodeName()))
|
||||
holder.appendChild(new Element("br"));
|
||||
}
|
||||
}
|
||||
return document;
|
||||
}
|
||||
|
||||
static Document sanitizeView(Context context, Document parsed, boolean show_images) {
|
||||
try {
|
||||
return sanitize(context, parsed, true, show_images);
|
||||
|
||||
Reference in New Issue
Block a user