Remove PGP inline armor headers

This commit is contained in:
M66B 2018-11-10 18:28:32 +00:00
parent d988f43e0b
commit 45016d8720
2 changed files with 7 additions and 1 deletions

View File

@ -999,11 +999,17 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
if (message.content) {
String body = message.read(context);
if (body != null) {
// https://tools.ietf.org/html/rfc4880#section-6.2
int begin = body.indexOf(PGP_BEGIN_MESSAGE);
int end = body.indexOf(PGP_END_MESSAGE);
if (begin >= 0 && begin < end) {
String section = body.substring(begin, end + PGP_END_MESSAGE.length());
section = section.replace("<br />", "\n\r");
String[] lines = section.split("<br />");
List<String> disarmored = new ArrayList<>();
for (String line : lines)
if (!TextUtils.isEmpty(line) && !line.contains(": "))
disarmored.add(line);
section = TextUtils.join("\n\r", disarmored);
inline = true;
encrypted = new ByteArrayInputStream(section.getBytes());