Fixed finding Usenet signature

This commit is contained in:
M66B 2019-08-22 20:31:40 +02:00
parent 6baac38747
commit 848496d3eb
1 changed files with 12 additions and 8 deletions

View File

@ -112,6 +112,8 @@ import com.google.android.material.snackbar.Snackbar;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.jsoup.nodes.TextNode;
import org.openintents.openpgp.OpenPgpError; import org.openintents.openpgp.OpenPgpError;
import org.openintents.openpgp.util.OpenPgpApi; import org.openintents.openpgp.util.OpenPgpApi;
import org.openintents.openpgp.util.OpenPgpServiceConnection; import org.openintents.openpgp.util.OpenPgpServiceConnection;
@ -2233,23 +2235,25 @@ public class FragmentCompose extends FragmentBase {
if (usenet) { if (usenet) {
Document rdoc = Jsoup.parse(refText); Document rdoc = Jsoup.parse(refText);
Element signature = null; Node signature = null;
for (Element e : rdoc.select("*")) for (Element e : rdoc.select("*"))
if ("-- ".equals(e.wholeText())) for (Node node : e.childNodes())
signature = e; if (node instanceof TextNode &&
"--".equals(((TextNode) node).text().trim()))
signature = node;
if (signature != null) { if (signature != null) {
List<Element> tbd = new ArrayList<>(); List<Node> tbd = new ArrayList<>();
tbd.add(signature); tbd.add(signature);
Element next = signature.nextElementSibling(); Node next = signature.nextSibling();
while (next != null) { while (next != null) {
tbd.add(0, next); tbd.add(0, next);
next = next.nextElementSibling(); next = next.nextSibling();
} }
for (Element e : tbd) for (Node n : tbd)
e.remove(); n.remove();
if (rdoc.body() != null) if (rdoc.body() != null)
refText = rdoc.body().html(); refText = rdoc.body().html();