1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-06-27 22:14:50 +02:00

UserID: prevent double angle brackets around email address

This commit is contained in:
Paul Schaub 2021-02-07 03:12:35 +01:00
parent 6386579376
commit ab39f0e2f3
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -37,7 +37,7 @@ public final class UserId implements CharSequence {
sb.append(" (").append(comment).append(')'); sb.append(" (").append(comment).append(')');
} }
if (email != null) { if (email != null) {
sb.append(sb.length() != 0 ? " <" : '<').append(email).append('>'); sb.append(sb.length() != 0 ? ' ' : "").append(email);
} }
return sb.toString(); return sb.toString();
} }
@ -98,7 +98,7 @@ public final class UserId implements CharSequence {
if (email == null) { if (email == null) {
throw new IllegalArgumentException("Email must not be null."); throw new IllegalArgumentException("Email must not be null.");
} }
return new UserId(name, comment, email); return new UserId(name, comment, email.matches("^<.+>$") ? email : '<' + email + '>');
} }
public UserId noEmail() { public UserId noEmail() {