You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by "chibenwa (via GitHub)" <gi...@apache.org> on 2024/03/01 16:05:08 UTC
Re: [PR] JAMES-4008 JMAP - Email/set - Should be able to save a draft with invalid email address [james-project]
chibenwa commented on code in PR #2040:
URL: https://github.com/apache/james-project/pull/2040#discussion_r1509204762
##########
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala:
##########
@@ -337,6 +338,24 @@ class EmailSubmissionSetMethod @Inject()(serializer: EmailSubmissionSetSerialize
Failure(new IllegalArgumentException("Invalid delayed time!"))
}
+ def validateMimeMessages(mimeMessage: MimeMessage) : SMono[MimeMessage] = validateMailAddressHeaderMimeMessage(mimeMessage)
+ private def validateMailAddressHeaderMimeMessage(mimeMessage: MimeMessage): SMono[MimeMessage] =
+ SFlux.fromIterable(Map("to" -> Option(mimeMessage.getRecipients(RecipientType.TO)).toList.flatten,
+ "cc" -> Option(mimeMessage.getRecipients(RecipientType.CC)).toList.flatten,
+ "bcc" -> Option(mimeMessage.getRecipients(RecipientType.BCC)).toList.flatten,
+ "from" -> Option(mimeMessage.getFrom).toList.flatten,
+ "sender" -> Option(mimeMessage.getSender).toList,
+ "replyTo" -> Option(mimeMessage.getReplyTo).toList.flatten))
+ .doOnNext { case (headerName, addresses) => (headerName, addresses.foreach(address => validateMailAddress(headerName, address))) }
+ .`then`()
+ .`then`(SMono.just(mimeMessage))
+
+ private def validateMailAddress(headName: String, address: Address): MailAddress =
+ Try(new MailAddress(address.toString)) match {
Review Comment:
```
Try(new MailAddress(address.getAddress)) match {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org