Autolink on send

pull/196/head
M66B 5 years ago
parent fecd64c25c
commit 772eeb6400

@ -1010,7 +1010,27 @@ public class HtmlHelper {
}
// Autolink
if (view) {
if (view)
autoLink(document);
// Selective new lines
for (Element div : document.select("div"))
div.tagName("span");
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
for (Element span : document.select("span"))
if (!TextUtils.isEmpty(span.attr("color")))
span.tagName("font");
if (document.body() == null) {
Log.e("Sanitize without body");
document.normalise();
}
return document;
}
static void autoLink(Document document) {
// https://en.wikipedia.org/wiki/List_of_URI_schemes
// xmpp:[<user>]@<host>[:<port>]/[<resource>][?<query>]
// geo:<lat>,<lon>[,<alt>][;u=<uncertainty>]
@ -1100,23 +1120,6 @@ public class HtmlHelper {
}, document);
}
// Selective new lines
for (Element div : document.select("div"))
div.tagName("span");
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
for (Element span : document.select("span"))
if (!TextUtils.isEmpty(span.attr("color")))
span.tagName("font");
if (document.body() == null) {
Log.e("Sanitize without body");
document.normalise();
}
return document;
}
static void normalizeNamespaces(Document parsed, boolean display_hidden) {
// <html xmlns:v="urn:schemas-microsoft-com:vml"
// xmlns:o="urn:schemas-microsoft-com:office:office"

@ -623,6 +623,8 @@ public class MessageHelper {
// When sending message
if (identity != null && send) {
HtmlHelper.autoLink(document);
for (Element child : document.body().children())
if (!TextUtils.isEmpty(child.text()) &&
TextUtils.isEmpty(child.attr("fairemail"))) {

Loading…
Cancel
Save