You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2017/08/22 08:54:07 UTC

[2/5] james-jsieve git commit: JSIEVE-107 Decode headers before returning back

JSIEVE-107 Decode headers before returning back


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

Branch: refs/heads/master
Commit: 3f68001e82d1679d969d39b509cae2ef34245c0d
Parents: 8ce6d21
Author: Daniele Depetrini <da...@infocert.it>
Authored: Mon Jun 6 15:40:52 2016 +0200
Committer: benwa <bt...@linagora.com>
Committed: Tue Aug 22 15:53:23 2017 +0700

----------------------------------------------------------------------
 .../apache/jsieve/util/check/ScriptCheckMailAdapter.java    | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-jsieve/blob/3f68001e/util/src/main/java/org/apache/jsieve/util/check/ScriptCheckMailAdapter.java
----------------------------------------------------------------------
diff --git a/util/src/main/java/org/apache/jsieve/util/check/ScriptCheckMailAdapter.java b/util/src/main/java/org/apache/jsieve/util/check/ScriptCheckMailAdapter.java
index fbb71c9..6a06c5c 100644
--- a/util/src/main/java/org/apache/jsieve/util/check/ScriptCheckMailAdapter.java
+++ b/util/src/main/java/org/apache/jsieve/util/check/ScriptCheckMailAdapter.java
@@ -34,6 +34,7 @@ import javax.mail.MessagingException;
 import java.io.IOException;
 import java.util.*;
 import javax.mail.internet.MimeUtility;
+import java.io.UnsupportedEncodingException;
 
 /**
  * Checks script execution for an email. The wrapped email is set by called
@@ -141,10 +142,12 @@ public class ScriptCheckMailAdapter implements MailAdapter {
                     //We need to do unfold headers here
                     result = new LinkedList<String>();
                     for (String value: values)
-                        result.add(MimeUtility.unfold(value));
+                        result.add(MimeUtility.decodeText(MimeUtility.unfold(value)));
                 }
             } catch (MessagingException e) {
                 throw new SieveMailException(e);
+            } catch (UnsupportedEncodingException e) {
+                throw new SieveMailException(e);
             }
         }
         return result;
@@ -265,7 +268,7 @@ public class ScriptCheckMailAdapter implements MailAdapter {
                 final Header header = (Header) en.nextElement();
                 final String name = header.getName();
                 if (name.trim().equalsIgnoreCase(headerName)) {
-                    builder.addAddresses(MimeUtility.unfold(header.getValue()));
+                    builder.addAddresses(MimeUtility.decodeText(MimeUtility.unfold(header.getValue())));
                 }
             }
 
@@ -274,6 +277,8 @@ public class ScriptCheckMailAdapter implements MailAdapter {
 
         } catch (MessagingException ex) {
             throw new SieveMailException(ex);
+        } catch (UnsupportedEncodingException ex) {
+            throw new SieveMailException(ex);
         } catch (ParseException ex) {
             throw new SieveMailException(ex);
         }


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