From 6e2a7015a551333fa8b6c06124366d04bd675e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=99=8D=EC=B0=AC=ED=9D=AC?= Date: Tue, 26 Nov 2024 21:09:36 +0900 Subject: [PATCH 1/2] refact RcptCommand regex --- .../java/com/icegreen/greenmail/smtp/commands/RcptCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/greenmail-core/src/main/java/com/icegreen/greenmail/smtp/commands/RcptCommand.java b/greenmail-core/src/main/java/com/icegreen/greenmail/smtp/commands/RcptCommand.java index 1a81a873e..91dda6d0f 100644 --- a/greenmail-core/src/main/java/com/icegreen/greenmail/smtp/commands/RcptCommand.java +++ b/greenmail-core/src/main/java/com/icegreen/greenmail/smtp/commands/RcptCommand.java @@ -26,7 +26,7 @@ */ public class RcptCommand extends SmtpCommand { - static Pattern param = Pattern.compile("RCPT TO:\\s?<([^>]+)>", + static Pattern param = Pattern.compile("RCPT TO:\\s?<([^>]*)>.*", Pattern.CASE_INSENSITIVE); @Override From fb756024a7638ab371790dfd3db190e15cd7296d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=99=8D=EC=B0=AC=ED=9D=AC?= Date: Tue, 26 Nov 2024 21:12:37 +0900 Subject: [PATCH 2/2] add test rcptToWithParameter --- .../icegreen/greenmail/smtp/SMTPCommandTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/greenmail-core/src/test/java/com/icegreen/greenmail/smtp/SMTPCommandTest.java b/greenmail-core/src/test/java/com/icegreen/greenmail/smtp/SMTPCommandTest.java index cc3002490..6db22d12a 100644 --- a/greenmail-core/src/test/java/com/icegreen/greenmail/smtp/SMTPCommandTest.java +++ b/greenmail-core/src/test/java/com/icegreen/greenmail/smtp/SMTPCommandTest.java @@ -125,4 +125,18 @@ public void mailSenderAUTHSuffix() throws IOException, MessagingException { } } + + @Test + public void rcptToWithParameter() throws IOException, MessagingException { + Session smtpSession = greenMail.getSmtp().createSession(); + + try (SMTPTransport smtpTransport = new SMTPTransport(smtpSession, smtpURL)) { + Socket smtpSocket = new Socket(hostAddress, port); // Closed by transport + smtpTransport.connect(smtpSocket); + assertThat(smtpTransport.isConnected()).isTrue(); + smtpTransport.issueCommand("MAIL FROM: ", -1); + smtpTransport.issueCommand("RCPT TO: NOTIFY=SUCCESS,FAILURE", -1); + assertThat(smtpTransport.getLastServerResponse()).isEqualToNormalizingWhitespace("250 OK"); + } + } }