From f1494f83ff7dd9c7d0ebdb176d36293f42297988 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Wed, 3 Sep 2014 13:05:22 +0200 Subject: [PATCH] fixed pgp signature creation --- .../siacs/conversations/crypto/PgpEngine.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/eu/siacs/conversations/crypto/PgpEngine.java b/src/eu/siacs/conversations/crypto/PgpEngine.java index 65b7ccc77..7b5ef905c 100644 --- a/src/eu/siacs/conversations/crypto/PgpEngine.java +++ b/src/eu/siacs/conversations/crypto/PgpEngine.java @@ -292,9 +292,25 @@ public class PgpEngine { switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) { case OpenPgpApi.RESULT_CODE_SUCCESS: StringBuilder signatureBuilder = new StringBuilder(); - String[] lines = os.toString().split("\n"); - for (int i = 7; i < lines.length - 1; ++i) { - signatureBuilder.append(lines[i].trim()); + try { + os.flush(); + String[] lines = os.toString().split("\n"); + boolean sig = false; + for(String line : lines) { + if (sig) { + if (line.contains("END PGP SIGNATURE")) { + sig = false; + } else { + signatureBuilder.append(line.trim()); + } + } + if (line.contains("BEGIN PGP SIGNATURE")) { + sig = true; + } + } + } catch (IOException e) { + callback.error(R.string.openpgp_error, account); + return; } account.setKey("pgp_signature", signatureBuilder.toString()); callback.success(account);