JAMES-1900 JSieve header instruction should unfold and decode headers
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/110db27d Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/110db27d Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/110db27d Branch: refs/heads/master Commit: 110db27d6831b9089cb1237d104c04806e78223d Parents: beefb43 Author: benwa <[email protected]> Authored: Fri May 5 11:05:05 2017 +0700 Committer: benwa <[email protected]> Committed: Mon Jun 5 20:24:51 2017 +0700 ---------------------------------------------------------------------- .../mailets/delivery/SieveIntegrationTest.java | 20 +++ .../mailets/src/test/resources/eml/gmail.eml | 154 +++++++++++++++++++ .../mailets/delivery/headerEncodedFolded.script | 26 ++++ server/pom.xml | 2 +- 4 files changed, 201 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/110db27d/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java index 04a4b6c..8d7c43b 100644 --- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java +++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java @@ -44,6 +44,7 @@ import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; @@ -264,6 +265,25 @@ public class SieveIntegrationTest { assertThat(mail.getAttribute(MailStore.DELIVERY_PATH_PREFIX + LOCAL_PART)).isEqualTo(expressMailboxNameWithSlash(NOT_SELECTED_MAILBOX.getName())); } + @Ignore("Waiting for JAMES-1900 JSieve part to be merged") + @Test + public void headerInstructionShouldSupportFoldedEncodedHeaders() throws Exception { + prepareTestUsingScript("org/apache/james/transport/mailets/delivery/headerEncodedFolded.script"); + + FakeMail mail = FakeMail.builder() + .mimeMessage(MimeMessageBuilder.mimeMessageFromStream( + ClassLoader.getSystemResourceAsStream("eml/gmail.eml"))) + .state(Mail.DEFAULT) + .recipient(new MailAddress(RECEIVER_DOMAIN_COM)) + .sender(new MailAddress("[email protected]")) + .build(); + testee.service(mail); + + assertThat(mail.getAttribute(MailStore.DELIVERY_PATH_PREFIX + LOCAL_PART)) + .isEqualTo(expressMailboxNameWithSlash(SELECTED_MAILBOX.getName())); + } + + @Test public void headerScriptShouldWorkIfHeaderIsPresent() throws Exception { prepareTestUsingScript("org/apache/james/transport/mailets/delivery/header.script"); http://git-wip-us.apache.org/repos/asf/james-project/blob/110db27d/server/mailet/mailets/src/test/resources/eml/gmail.eml ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/test/resources/eml/gmail.eml b/server/mailet/mailets/src/test/resources/eml/gmail.eml new file mode 100644 index 0000000..1b95cba --- /dev/null +++ b/server/mailet/mailets/src/test/resources/eml/gmail.eml @@ -0,0 +1,154 @@ +Return-Path: <[email protected]> +Subject: Fwd: Invitation: (Aucun objet) - ven. 20 janv. 2017 14:00 - 15:00 + (CET) ([email protected]) +To: =?UTF-8?Q?Beno=c3=aet_TELLIER?= + <[email protected]> +From: aduprat <[email protected]> +X-Forwarded-Message-Id: <[email protected]> +Message-ID: <[email protected]> +Date: Thu, 19 Jan 2017 20:36:37 +0100 +MIME-Version: 1.0 +In-Reply-To: <[email protected]> +Content-Type: multipart/mixed; + boundary="------------17D96D411CBD55D8239A8C1F" + +This is a multi-part message in MIME format. +--------------17D96D411CBD55D8239A8C1F +Content-Type: multipart/alternative; + boundary="------------64D716A3DDAEC185D3E67448" + + +--------------64D716A3DDAEC185D3E67448 +Content-Type: text/plain; charset=utf-8; format=flowed +Content-Transfer-Encoding: 8bit + + + + +-------- Message transéré -------- +Sujet : Invitation: (Aucun objet) - ven. 20 janv. 2017 14:00 - 15:00 +(CET) ([email protected]) +Date : Thu, 19 Jan 2017 19:18:23 +0000 +De : Antoine Duprat <[email protected]> +Répondre à : [email protected] +Pour : [email protected] + + + + +--------------64D716A3DDAEC185D3E67448 +Content-Type: text/html; charset=utf-8 +Content-Transfer-Encoding: 8bit + +<html> + <head> + + <meta http-equiv="content-type" content="text/html; charset=utf-8"> + </head> + <body bgcolor="#FFFFFF" text="#000000"> + <p><br> + </p> + <div class="moz-forward-container"><br> + <br> + -------- Message transéré -------- + <table class="moz-email-headers-table" border="0" cellpadding="0" + cellspacing="0"> + <tbody> + <tr> + <th align="RIGHT" valign="BASELINE" nowrap="nowrap">Sujetà : + </th> + <td>Invitation: (Aucun objet) - ven. 20 janv. 2017 14:00 - + 15:00 (CET) (<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>)</td> + </tr> + <tr> + <th align="RIGHT" valign="BASELINE" nowrap="nowrap">Dateà : </th> + <td>Thu, 19 Jan 2017 19:18:23 +0000</td> + </tr> + <tr> + <th align="RIGHT" valign="BASELINE" nowrap="nowrap">Deà : </th> + <td>Antoine Duprat <a class="moz-txt-link-rfc2396E" href="mailto:[email protected]"><[email protected]></a></td> + </tr> + <tr> + <th align="RIGHT" valign="BASELINE" nowrap="nowrap">Répondre + à à : </th> + <td><a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a></td> + </tr> + <tr> + <th align="RIGHT" valign="BASELINE" nowrap="nowrap">Pourà : </th> + <td><a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a></td> + </tr> + </tbody> + </table> + <br> + <br> + </div> + </body> +</html> + +--------------64D716A3DDAEC185D3E67448-- + +--------------17D96D411CBD55D8239A8C1F +Content-Type: text/calendar; + name="Portion de message joint" +Content-Transfer-Encoding: 8bit +Content-Disposition: attachment; + filename="Portion de message joint" + +BEGIN:VCALENDAR +PRODID:-//Google Inc//Google Calendar 70.9054//EN +VERSION:2.0 +CALSCALE:GREGORIAN +METHOD:REQUEST +BEGIN:VEVENT +DTSTART:20170120T130000Z +DTEND:20170120T140000Z +DTSTAMP:20170119T191823Z +ORGANIZER;CN=Antoine Duprat:mailto:[email protected] +UID:[email protected] +ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP= + TRUE;[email protected];X-NUM-GUESTS=0:mailto:[email protected] +ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=TRUE + ;CN=Antoine Duprat;X-NUM-GUESTS=0:mailto:[email protected] +CREATED:20170119T191823Z +DESCRIPTION:Affichez votre evenement sur la page https://www.google.com/cal + endar/event?action=VIEW&eid=YWg4Nms1bTM0MmJtY3JiZTlraGtraGxuMDAgYWR1cHJhdEB + saW5hZ29yYS5jb20&tok=MTkjYW50ZHVwcmF0QGdtYWlsLmNvbTg1OTM5NWM4MGRlYmE1YTI4Nz + RjN2UyNjU0M2YyZmQ4NzRkNThhYTQ&ctz=Europe/Paris&hl=fr. +LAST-MODIFIED:20170119T191823Z +LOCATION: +SEQUENCE:0 +STATUS:CONFIRMED +SUMMARY: +TRANSP:OPAQUE +END:VEVENT +END:VCALENDAR + + +--------------17D96D411CBD55D8239A8C1F +Content-Type: application/ics; + name="invite.ics" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; + filename="invite.ics" + +QkVHSU46VkNBTEVOREFSDQpQUk9ESUQ6LS8vR29vZ2xlIEluYy8vR29vZ2xlIENhbGVuZGFy +IDcwLjkwNTQvL0VODQpWRVJTSU9OOjIuMA0KQ0FMU0NBTEU6R1JFR09SSUFODQpNRVRIT0Q6 +UkVRVUVTVA0KQkVHSU46VkVWRU5UDQpEVFNUQVJUOjIwMTcwMTIwVDEzMDAwMFoNCkRURU5E +OjIwMTcwMTIwVDE0MDAwMFoNCkRUU1RBTVA6MjAxNzAxMTlUMTkxODIzWg0KT1JHQU5JW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k1FRA0KU1VNTUFSWToNClRSQU5TUDpPUEFRVUUNCkVORDpWRVZFTlQNCkVO +RDpWQ0FMRU5EQVINCg== +--------------17D96D411CBD55D8239A8C1F-- http://git-wip-us.apache.org/repos/asf/james-project/blob/110db27d/server/mailet/mailets/src/test/resources/org/apache/james/transport/mailets/delivery/headerEncodedFolded.script ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/test/resources/org/apache/james/transport/mailets/delivery/headerEncodedFolded.script b/server/mailet/mailets/src/test/resources/org/apache/james/transport/mailets/delivery/headerEncodedFolded.script new file mode 100644 index 0000000..b9f506d --- /dev/null +++ b/server/mailet/mailets/src/test/resources/org/apache/james/transport/mailets/delivery/headerEncodedFolded.script @@ -0,0 +1,26 @@ +################################################################ +# Licensed to the Apache Software Foundation (ASF) under one # +# or more contributor license agreements. See the NOTICE file # +# distributed with this work for additional information # +# regarding copyright ownership. The ASF licenses this file # +# to you under the Apache License, Version 2.0 (the # +# "License"); you may not use this file except in compliance # +# with the License. You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, # +# software distributed under the License is distributed on an # +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # +# KIND, either express or implied. See the License for the # +# specific language governing permissions and limitations # +# under the License. # +################################################################ + +require "fileinto"; + +if header :contains ["To"] ["Benoît TELLIER <[email protected]>"] { + fileinto "INBOX.select"; +} else { + fileinto "INBOX.not.selected"; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/110db27d/server/pom.xml ---------------------------------------------------------------------- diff --git a/server/pom.xml b/server/pom.xml index f2749ee..f9cb099 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -128,7 +128,7 @@ <javax.activation.groupId>javax.activation</javax.activation.groupId> <javax.activation.artifactId>activation</javax.activation.artifactId> <jackrabbit.version>2.5.2</jackrabbit.version> - <jsieve.version>0.6</jsieve.version> + <jsieve.version>0.7-SNAPSHOT</jsieve.version> <spring.version>3.2.14.RELEASE</spring.version> <geronimo-jms-spec.version>1.1.1</geronimo-jms-spec.version> <h2.version>1.3.170</h2.version> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
