From 1fa9ebd227cf972c854c9bb3ea8f734979c33ec6 Mon Sep 17 00:00:00 2001 From: Russ Poetker Date: Wed, 18 Dec 2024 14:29:23 -0500 Subject: [PATCH] Cleanse nihms email content --- .../pass/deposit/service/NihmsReceiveMailService.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/service/NihmsReceiveMailService.java b/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/service/NihmsReceiveMailService.java index 6ee8ce4e..0aeef643 100644 --- a/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/service/NihmsReceiveMailService.java +++ b/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/service/NihmsReceiveMailService.java @@ -31,6 +31,7 @@ import jakarta.mail.internet.AddressException; import jakarta.mail.internet.InternetAddress; import jakarta.mail.internet.MimeMessage; +import org.apache.commons.lang3.StringUtils; import org.eclipse.pass.deposit.provider.nihms.NihmsAssembler; import org.eclipse.pass.support.client.PassClient; import org.eclipse.pass.support.client.PassClientSelector; @@ -99,14 +100,15 @@ public void handleReceivedMail(MimeMessage receivedMessage) { } LOG.warn("Email is from Nihms"); String content = getHtmlText(receivedMessage); - LOG.warn("Nihms Email content:" + content); + String cleansedContent = StringUtils.normalizeSpace(content); + LOG.warn("Nihms Email content:" + cleansedContent); if (Objects.isNull(content)) { LOG.error("No HTML content found in nihms email: " + receivedMessage.getSubject()); return; } - Elements messageElements = getMessageElements(content); + Elements messageElements = getMessageElements(cleansedContent); if (messageElements.isEmpty()) { - LOG.error("No messages found in nihms email: " + content); + LOG.error("No messages found in nihms email: " + cleansedContent); return; } processMessages(messageElements);