james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject james-jsieve git commit: JAMES-1900 header JSIEVE instruction should unfold and decode headers
Date Mon, 08 May 2017 02:32:43 GMT
Repository: james-jsieve
Updated Branches:
  refs/heads/master ef01c3242 -> ffeccf9af


JAMES-1900 header JSIEVE instruction should unfold and decode headers


Project: http://git-wip-us.apache.org/repos/asf/james-jsieve/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-jsieve/commit/ffeccf9a
Tree: http://git-wip-us.apache.org/repos/asf/james-jsieve/tree/ffeccf9a
Diff: http://git-wip-us.apache.org/repos/asf/james-jsieve/diff/ffeccf9a

Branch: refs/heads/master
Commit: ffeccf9af8978140ce3c840cbea1cbbcee2863a5
Parents: ef01c32
Author: benwa <btellier@linagora.com>
Authored: Fri May 5 10:59:00 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Mon May 8 09:32:20 2017 +0700

----------------------------------------------------------------------
 core/pom.xml                                       |  5 +++++
 .../main/java/org/apache/jsieve/tests/Header.java  |  9 ++++++---
 .../test/java/org/apache/jsieve/HeaderTest.java    | 17 ++++++++++++++++-
 pom.xml                                            |  6 ++++++
 4 files changed, 33 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-jsieve/blob/ffeccf9a/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index cade211..829f292 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -46,6 +46,11 @@
     </distributionManagement>
 
     <dependencies>
+
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>apache-mime4j-core</artifactId>
+        </dependency>
         <dependency>
             <groupId>commons-logging</groupId>
             <artifactId>commons-logging</artifactId>

http://git-wip-us.apache.org/repos/asf/james-jsieve/blob/ffeccf9a/core/src/main/java/org/apache/jsieve/tests/Header.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/jsieve/tests/Header.java b/core/src/main/java/org/apache/jsieve/tests/Header.java
index 014f2c7..95fce8a 100644
--- a/core/src/main/java/org/apache/jsieve/tests/Header.java
+++ b/core/src/main/java/org/apache/jsieve/tests/Header.java
@@ -30,6 +30,9 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
 
+import org.apache.james.mime4j.codec.DecodeMonitor;
+import org.apache.james.mime4j.codec.DecoderUtil;
+import org.apache.james.mime4j.util.MimeUtil;
 import org.apache.jsieve.Argument;
 import org.apache.jsieve.Arguments;
 import org.apache.jsieve.SieveContext;
@@ -199,10 +202,10 @@ public class Header extends AbstractTest {
             }
         // Iterate over the header values looking for a match
         boolean isMatched = false;
-        Iterator headerValuesIter = headerValues.iterator();
+        Iterator<String> headerValuesIter = headerValues.iterator();
         while (!isMatched && headerValuesIter.hasNext()) {
-            isMatched = match(comparator, matchType, (String) headerValuesIter
-                    .next(), keys, context);
+            String headerValue = MimeUtil.unscrambleHeaderValue(headerValuesIter.next());
+            isMatched = match(comparator, matchType, headerValue, keys, context);
         }
         return isMatched;
     }

http://git-wip-us.apache.org/repos/asf/james-jsieve/blob/ffeccf9a/core/src/test/java/org/apache/jsieve/HeaderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/jsieve/HeaderTest.java b/core/src/test/java/org/apache/jsieve/HeaderTest.java
index e15539e..67b1f59 100644
--- a/core/src/test/java/org/apache/jsieve/HeaderTest.java
+++ b/core/src/test/java/org/apache/jsieve/HeaderTest.java
@@ -37,7 +37,7 @@ public class HeaderTest {
     /**
      * Test for Test 'header'
      */
-    @org.junit.Test
+    @Test
     public void testHeaderIsTrue() {
         boolean isTestPassed = false;
         String script = "if header :is \"X-Caffeine\" \"C8H10N4O2\" {throwTestException;}";
@@ -57,6 +57,21 @@ public class HeaderTest {
     /**
      * Test for Test 'header'
      */
+    @Test(expected = ThrowTestException.TestException.class)
+    public void testFoldedEncodedHeader() throws Exception {
+        String script = "if header :is \"To\" \"BenoƮt TELLIER <tellier@linagora.com>\"
{throwTestException;}";
+
+
+        SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
+        mail.getMessage().addHeader("To", "=?UTF-8?Q?Beno=c3=aet_TELLIER?=\r\n" +
+            " <tellier@linagora.com>");
+
+        JUnitUtils.interpret(mail, script);
+    }
+
+    /**
+     * Test for Test 'header'
+     */
     @Test
     public void testHeaderCaseInsensitivity() {
         boolean isTestPassed = false;

http://git-wip-us.apache.org/repos/asf/james-jsieve/blob/ffeccf9a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ba4dab6..6c380bf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -91,12 +91,18 @@
         <mockito-core.version>1.9.0</mockito-core.version>
         <assertj.version>1.7.1</assertj.version>
         <guava.version>18.0</guava.version>
+        <mime4j.version>0.8.1-SNAPSHOT</mime4j.version>
     </properties>
 
     <dependencyManagement>
         <dependencies>
             <dependency>
                 <groupId>org.apache.james</groupId>
+                <artifactId>apache-mime4j-core</artifactId>
+                <version>${mime4j.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.james</groupId>
                 <artifactId>apache-jsieve</artifactId>
                 <version>${project.version}</version>
             </dependency>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message