mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
minor layout fixes, replace non breakable spaces if found in an encrypted armored message, as they break the decryption, the HTML representation of GMail introduces them for empty lines ending in a normal space, also adjusted the PGP_MESSAGE regex to allow for spaces after the -----, which seems to be added by some implementations
This commit is contained in:
parent
b8009d6d43
commit
acd71a45c0
@ -29,7 +29,7 @@
|
||||
android:src="@drawable/encrypted"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"/>
|
||||
android:layout_gravity="center_vertical"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
|
@ -122,7 +122,7 @@ public class Apg {
|
||||
protected static Vector<PGPSecretKeyRing> mSecretKeyRings;
|
||||
|
||||
public static Pattern PGP_MESSAGE =
|
||||
Pattern.compile(".*?(-----BEGIN PGP MESSAGE-----\n.*?-----END PGP MESSAGE-----).*",
|
||||
Pattern.compile(".*?(-----BEGIN PGP MESSAGE-----.*?-----END PGP MESSAGE-----).*",
|
||||
Pattern.DOTALL);
|
||||
|
||||
protected static boolean mInitialized = false;
|
||||
@ -1135,6 +1135,7 @@ public class Apg {
|
||||
}
|
||||
|
||||
public static void encrypt(InputStream inStream, OutputStream outStream,
|
||||
boolean armored,
|
||||
long encryptionKeyIds[], long signatureKeyId,
|
||||
String signaturePassPhrase,
|
||||
ProgressDialogUpdater progress)
|
||||
@ -1142,11 +1143,16 @@ public class Apg {
|
||||
NoSuchAlgorithmException, SignatureException {
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
|
||||
ArmoredOutputStream armorOut = new ArmoredOutputStream(outStream);
|
||||
armorOut.setHeader("Version", FULL_VERSION);
|
||||
OutputStream out = armorOut;
|
||||
ArmoredOutputStream armorOut = null;
|
||||
OutputStream out = null;
|
||||
OutputStream encryptOut = null;
|
||||
|
||||
if (armored) {
|
||||
armorOut = new ArmoredOutputStream(outStream);
|
||||
armorOut.setHeader("Version", FULL_VERSION);
|
||||
out = armorOut;
|
||||
} else {
|
||||
out = outStream;
|
||||
}
|
||||
PGPSecretKey signingKey = null;
|
||||
PGPSecretKeyRing signingKeyRing = null;
|
||||
PGPPrivateKey signaturePrivateKey = null;
|
||||
|
@ -190,6 +190,8 @@ public class DecryptMessageActivity extends Activity
|
||||
Matcher matcher = Apg.PGP_MESSAGE.matcher(data);
|
||||
if (matcher.matches()) {
|
||||
data = matcher.group(1);
|
||||
// replace non breakable spaces
|
||||
data = data.replaceAll("\\xa0", " ");
|
||||
mMessage.setText(data);
|
||||
}
|
||||
}
|
||||
@ -312,8 +314,9 @@ public class DecryptMessageActivity extends Activity
|
||||
Bundle data = new Bundle();
|
||||
Message msg = new Message();
|
||||
|
||||
ByteArrayInputStream in =
|
||||
new ByteArrayInputStream(mMessage.getText().toString().getBytes());
|
||||
String messageData = mMessage.getText().toString();
|
||||
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(messageData.getBytes());
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
try {
|
||||
|
@ -312,7 +312,8 @@ public class EncryptMessageActivity extends Activity
|
||||
|
||||
try {
|
||||
if (mEncryptionKeyIds != null && mEncryptionKeyIds.length > 0) {
|
||||
Apg.encrypt(in, out, mEncryptionKeyIds, mSignatureKeyId, Apg.getPassPhrase(), this);
|
||||
Apg.encrypt(in, out, true, mEncryptionKeyIds, mSignatureKeyId,
|
||||
Apg.getPassPhrase(), this);
|
||||
data.putString("message", new String(out.toByteArray()));
|
||||
} else {
|
||||
Apg.sign(in, out, mSignatureKeyId, Apg.getPassPhrase(), this);
|
||||
|
Loading…
Reference in New Issue
Block a user