mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-14 20:59:39 +02:00
Enhance email regex in keyring
This new regex better matches the string format for identities as specified by the RFC. The email address is surrounded by <>. The new regex correctly parses identities like this: foo@bar.com <baz@foo.com> Resulting in baz@foo.com being returned. Without this fix, foo@bar.com was returned.
This commit is contained in:
parent
1088b6c8ae
commit
3a6e665e56
1 changed files with 2 additions and 2 deletions
|
@ -50,7 +50,7 @@ import org.pgpainless.signature.subpackets.SignatureSubpacketsUtil;
|
||||||
*/
|
*/
|
||||||
public class KeyRingInfo {
|
public class KeyRingInfo {
|
||||||
|
|
||||||
private static final Pattern PATTERN_EMAIL = Pattern.compile("[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}");
|
private static final Pattern PATTERN_EMAIL = Pattern.compile("<([^<>\\s]+@.+)>");
|
||||||
|
|
||||||
private final PGPKeyRing keys;
|
private final PGPKeyRing keys;
|
||||||
private final Signatures signatures;
|
private final Signatures signatures;
|
||||||
|
@ -423,7 +423,7 @@ public class KeyRingInfo {
|
||||||
for (String userId : userIds) {
|
for (String userId : userIds) {
|
||||||
Matcher matcher = PATTERN_EMAIL.matcher(userId);
|
Matcher matcher = PATTERN_EMAIL.matcher(userId);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
emails.add(matcher.group());
|
emails.add(matcher.group(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return emails;
|
return emails;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue