Skip to content

Commit

Permalink
Add handling of CRLF line ending
Browse files Browse the repository at this point in the history
  • Loading branch information
Awbmilne committed Oct 16, 2020
1 parent fc3dd86 commit 87d4bda
Showing 1 changed file with 3 additions and 2 deletions.
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 87d4bda

Please sign in to comment.