Github user btwood commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2111#discussion_r136573254
  
    --- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ExtractEmailHeaders.java
 ---
    @@ -168,21 +173,40 @@ public void process(final InputStream rawIn) throws 
IOException {
                                 }
                             }
                         }
    -                    if 
(Array.getLength(originalMessage.getAllRecipients()) > 0) {
    -                        for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.TO)); 
toCount++) {
    -                            attributes.put(EMAIL_HEADER_TO + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.TO)[toCount].toString());
    +
    +                    // Get Non-Strict Recipient Addresses
    +                    InternetAddress[] recipients;
    +                    if 
(originalMessage.getHeader(Message.RecipientType.TO.toString(), ",") != null) {
    +                        recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.TO.toString(),
 ","), false);
    +                        for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
    +                            attributes.put(EMAIL_HEADER_TO + "." + 
toCount, recipients[toCount].toString());
                             }
    -                        for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.BCC)); 
toCount++) {
    -                            attributes.put(EMAIL_HEADER_BCC + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.BCC)[toCount].toString());
    +                    }
    +                    if 
(originalMessage.getHeader(Message.RecipientType.BCC.toString(), ",") != null) {
    +                        recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.BCC.toString(),
 ","), false);
    +                        for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
    +                            attributes.put(EMAIL_HEADER_BCC + "." + 
toCount, recipients[toCount].toString());
                             }
    -                        for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.CC)); 
toCount++) {
    -                            attributes.put(EMAIL_HEADER_CC + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.CC)[toCount].toString());
    +                    }
    +                    if 
(originalMessage.getHeader(Message.RecipientType.CC.toString(), ",") != null) {
    +                        recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.CC.toString(),
 ","), false);
    +                        for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
    +                            attributes.put(EMAIL_HEADER_CC + "." + 
toCount, recipients[toCount].toString());
                             }
                         }
    -                    // Incredibly enough RFC-2822 specified From as a 
"mailbox-list" so an array I returned by getFrom
    -                    for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getFrom()); toCount++) {
    -                        attributes.put(EMAIL_HEADER_FROM + "." + toCount, 
originalMessage.getFrom()[toCount].toString());
    +
    +                    // Get Non-Strict Sender Addresses
    +                    InternetAddress[] sender = null;
    +                    if (originalMessage.getHeader("From",",") != null) {
    +                        sender = 
(InternetAddress[])ArrayUtils.addAll(sender, 
InternetAddress.parseHeader(originalMessage.getHeader("From", ","), false));
    +                    }
    +                    if (originalMessage.getHeader("Sender",",") != null) {
    +                        sender = 
(InternetAddress[])ArrayUtils.addAll(sender, 
InternetAddress.parseHeader(originalMessage.getHeader("Sender", ","), false));
    --- End diff --
    
    Also, I agree. We don't want to break anything for current users. If the 
expected behavior changes, we don't know how that impacts current users, 
because some may be relying on this to fail.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to