mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-20 21:27:07 +00:00
Remove relative links
This commit is contained in:
parent
d1f7ff475f
commit
8a9a3fb099
2 changed files with 13 additions and 2 deletions
|
@ -2520,6 +2520,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}
|
||||
|
||||
HtmlHelper.cleanup(document);
|
||||
HtmlHelper.removeRelativeLinks(document);
|
||||
|
||||
// Check for inline encryption
|
||||
boolean iencrypted = HtmlHelper.contains(document, new String[]{
|
||||
|
|
|
@ -914,7 +914,9 @@ public class HtmlHelper {
|
|||
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/q
|
||||
for (Element q : document.select("q")) {
|
||||
q.tagName("a");
|
||||
q.attr("href", q.attr("cite"));
|
||||
String cite = q.attr("cite");
|
||||
if (!TextUtils.isEmpty(cite) && !cite.trim().startsWith("#"))
|
||||
q.attr("href", cite);
|
||||
q.removeAttr("cite");
|
||||
}
|
||||
|
||||
|
@ -1159,7 +1161,7 @@ public class HtmlHelper {
|
|||
while (p != null && !linked)
|
||||
if ("a".equals(p.tagName())) {
|
||||
String href = p.attr("href");
|
||||
if (TextUtils.isEmpty(href) || href.equals("#"))
|
||||
if (TextUtils.isEmpty(href))
|
||||
break;
|
||||
if (!TextUtils.isEmpty(p.text()))
|
||||
break;
|
||||
|
@ -1237,6 +1239,14 @@ public class HtmlHelper {
|
|||
return document;
|
||||
}
|
||||
|
||||
static void removeRelativeLinks(Document document){
|
||||
for (Element a : document.select("a"))
|
||||
if (a.attr("href").trim().startsWith("#")) {
|
||||
a.tagName("span");
|
||||
a.removeAttr("href");
|
||||
}
|
||||
}
|
||||
|
||||
static void autoLink(Document document) {
|
||||
// https://en.wikipedia.org/wiki/List_of_URI_schemes
|
||||
// xmpp:[<user>]@<host>[:<port>]/[<resource>][?<query>]
|
||||
|
|
Loading…
Reference in a new issue