You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by dtrodrigues <gi...@git.apache.org> on 2018/06/12 02:38:36 UTC
[GitHub] nifi pull request #2787: NIFI-5252 - support arbitrary headers in PutEmail p...
GitHub user dtrodrigues opened a pull request:
https://github.com/apache/nifi/pull/2787
NIFI-5252 - support arbitrary headers in PutEmail processor
Thank you for submitting a contribution to Apache NiFi.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
- [ ] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
- [ ] Has your PR been rebased against the latest commit within the target branch (typically master)?
- [ ] Is your initial contribution a single, squashed commit?
### For code changes:
- [ ] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
- [ ] Have you written or updated unit tests to verify your changes?
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
- [ ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
- [ ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?
### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
### Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/dtrodrigues/nifi NIFI-5252
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/nifi/pull/2787.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #2787
----
commit 250736cc14ffb6c44925fe606b5de67d7a53638a
Author: Dustin Rodrigues <du...@...>
Date: 2018-06-12T02:00:28Z
NIFI-5252 - support arbitrary headers in PutEmail processor
----
---
[GitHub] nifi issue #2787: NIFI-5252 - support arbitrary headers in PutEmail processo...
Posted by dtrodrigues <gi...@git.apache.org>.
Github user dtrodrigues commented on the issue:
https://github.com/apache/nifi/pull/2787
moved regex compilation to when processor is scheduled and ensured header values are encoded appropriately
---
[GitHub] nifi pull request #2787: NIFI-5252 - support arbitrary headers in PutEmail p...
Posted by pvillard31 <gi...@git.apache.org>.
Github user pvillard31 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2787#discussion_r194632391
--- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutEmail.java ---
@@ -319,6 +330,15 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
message.setRecipients(RecipientType.CC, toInetAddresses(context, flowFile, CC));
message.setRecipients(RecipientType.BCC, toInetAddresses(context, flowFile, BCC));
+ final String attributeNameRegex = context.getProperty(ATTRIBUTE_NAME_REGEX).getValue();
+ final Pattern attributeNamePattern = attributeNameRegex == null ? null : Pattern.compile(attributeNameRegex);
--- End diff --
Could we move the compile outside the onTrigger call? I think it's better to make this call when the processor is scheduled.
---
[GitHub] nifi pull request #2787: NIFI-5252 - support arbitrary headers in PutEmail p...
Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2787#discussion_r194700389
--- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutEmail.java ---
@@ -319,6 +330,15 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
message.setRecipients(RecipientType.CC, toInetAddresses(context, flowFile, CC));
message.setRecipients(RecipientType.BCC, toInetAddresses(context, flowFile, BCC));
+ final String attributeNameRegex = context.getProperty(ATTRIBUTE_NAME_REGEX).getValue();
+ final Pattern attributeNamePattern = attributeNameRegex == null ? null : Pattern.compile(attributeNameRegex);
+ if (attributeNamePattern != null) {
+ for (final Map.Entry<String, String> entry : flowFile.getAttributes().entrySet()) {
+ if (attributeNamePattern.matcher(entry.getKey()).matches()) {
--- End diff --
There are rules about how the headers have to be encoded. We should use the MimeUtility to ensure everything is encoded correctly.
```
Note that RFC 822 headers must contain only US-ASCII characters, so a header that contains non US-ASCII characters must have been encoded by the caller as per the rules of RFC 2047.
```
[MimeUtility](https://docs.oracle.com/javaee/6/api/javax/mail/internet/MimeUtility.html)
We should also have tests for ensuring attributes with content that must be encoded are handled.
---
[GitHub] nifi issue #2787: NIFI-5252 - support arbitrary headers in PutEmail processo...
Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on the issue:
https://github.com/apache/nifi/pull/2787
The changes to the encoding looks good.
Thanks for the contribution!
+1
---
[GitHub] nifi pull request #2787: NIFI-5252 - support arbitrary headers in PutEmail p...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/nifi/pull/2787
---
[GitHub] nifi issue #2787: NIFI-5252 - support arbitrary headers in PutEmail processo...
Posted by pvillard31 <gi...@git.apache.org>.
Github user pvillard31 commented on the issue:
https://github.com/apache/nifi/pull/2787
LGTM - @ottobackwards can you have a look as well? if all looks good for you, will merge to master. Thanks guys!
---