diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysProxyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysProxyActivity.java index f57a0d5446..d3152bfc25 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysProxyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysProxyActivity.java @@ -138,8 +138,9 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { /** ─── Regex Explanation ─── * - Full String - - * (?<=\n)(?:KEY:OPENPGP4FPR:|KEY.*?https.*?\/pks\/lookup\?(?:op=get&)?search=0x|KEY.*?https:\/\/keys.openpgp.org\/vks\/v1\/by-fingerprint\/)([a-fA-F0-9]{40})(?=\n) + * (?<=\r?\n)(?:KEY:OPENPGP4FPR:|KEY.*?https.*?\/pks\/lookup\?(?:op=get&)?search=0x|KEY.*?https:\/\/keys.openpgp.org\/vks\/v1\/by-fingerprint\/)([a-fA-F0-9]{40})(?=\r?\n) * + * (?<=\r?\n) & (?=\r?\n) <- Make sure the string is on its own line (Reverse lookahead + lookahead) * ?:KEY:OPENPGP4FPR: <- OPENPGP4FPR values * KEY.*?https.*?\/pks\/lookup\?(?:op=get&)?search=0x <- Majority of SKS Server pool URLs * KEY.*?https:\/\/keys.openpgp.org\/vks\/v1\/by-fingerprint\/ <- keys.openpgp.org URLs @@ -156,7 +157,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { * KEY;MEDIATYPE=application/pgp-keys:https://pgp.mit.edu/pks/lookup?search=0xABAF11C65A2970B130ABE3C479BE3E4300411886 * KEY;MEDIATYPE=application/pgp-keys:https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xabaf11c65a2970b130abe3c479be3e4300411886 */ - private static final Pattern VCARD_KEY_PATTERN = Pattern.compile("(?<=\n)(?:KEY:OPENPGP4FPR:|KEY.*?https.*?\/pks\/lookup\?(?:op=get&)?search=0x|KEY.*?https:\/\/keys.openpgp.org\/vks\/v1\/by-fingerprint\/)([a-fA-F0-9]{40})(?=\n)"); + private static final Pattern VCARD_KEY_PATTERN = Pattern.compile("(?<=\r?\n)(?:KEY:OPENPGP4FPR:|KEY.*?https.*?\/pks\/lookup\?(?:op=get&)?search=0x|KEY.*?https:\/\/keys.openpgp.org\/vks\/v1\/by-fingerprint\/)([a-fA-F0-9]{40})(?=\r?\n)"); private void processScannedContent(String content) { // if a VCard was scanned, try to extract the KEY field