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 2018/05/22 08:58:44 UTC
[2/3] james-mime4j git commit: MIME4J-263 decoding encoded words with
empty encoded-text
MIME4J-263 decoding encoded words with empty encoded-text
Project: http://git-wip-us.apache.org/repos/asf/james-mime4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-mime4j/commit/db390c15
Tree: http://git-wip-us.apache.org/repos/asf/james-mime4j/tree/db390c15
Diff: http://git-wip-us.apache.org/repos/asf/james-mime4j/diff/db390c15
Branch: refs/heads/master
Commit: db390c15702eff7ba6b0cdb5855ffc5503bb9b5c
Parents: c33617d
Author: Artur Jablonski <aj...@ravenpack.com>
Authored: Fri Aug 18 11:51:40 2017 +0200
Committer: benwa <bt...@linagora.com>
Committed: Tue May 22 15:33:53 2018 +0700
----------------------------------------------------------------------
.../main/java/org/apache/james/mime4j/codec/DecoderUtil.java | 5 ++++-
.../java/org/apache/james/mime4j/codec/DecoderUtilTest.java | 6 ++++--
2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-mime4j/blob/db390c15/core/src/main/java/org/apache/james/mime4j/codec/DecoderUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/james/mime4j/codec/DecoderUtil.java b/core/src/main/java/org/apache/james/mime4j/codec/DecoderUtil.java
index 790b62a..dab1f20 100644
--- a/core/src/main/java/org/apache/james/mime4j/codec/DecoderUtil.java
+++ b/core/src/main/java/org/apache/james/mime4j/codec/DecoderUtil.java
@@ -35,7 +35,7 @@ import org.apache.james.mime4j.util.CharsetUtil;
public class DecoderUtil {
private static final Pattern PATTERN_ENCODED_WORD = Pattern.compile(
- "(.*?)=\\?(.+?)\\?(\\w)\\?(.+?)\\?=", Pattern.DOTALL);
+ "(.*?)=\\?(.+?)\\?(\\w)\\?(.*?)\\?=", Pattern.DOTALL);
/**
* Decodes a string containing quoted-printable encoded data.
@@ -183,6 +183,9 @@ public class DecoderUtil {
String encoding = matcher.group(3);
String encodedText = matcher.group(4);
+ if ("".equals(encodedText))
+ return "";
+
String decoded;
decoded = tryDecodeEncodedWord(mimeCharset, encoding, encodedText, monitor, fallback);
if (decoded == null) {
http://git-wip-us.apache.org/repos/asf/james-mime4j/blob/db390c15/core/src/test/java/org/apache/james/mime4j/codec/DecoderUtilTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/james/mime4j/codec/DecoderUtilTest.java b/core/src/test/java/org/apache/james/mime4j/codec/DecoderUtilTest.java
index 3a97de3..a33dd3c 100644
--- a/core/src/test/java/org/apache/james/mime4j/codec/DecoderUtilTest.java
+++ b/core/src/test/java/org/apache/james/mime4j/codec/DecoderUtilTest.java
@@ -99,8 +99,10 @@ public class DecoderUtilTest {
@Test
public void testEmptyEncodedTextIsIgnored() {
// encoded-text requires at least one character according to rfc 2047
- Assert.assertEquals("=?ISO-8859-1?Q??=", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?Q??="));
- Assert.assertEquals("=?ISO-8859-1?B??=", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?B??="));
+ // meanwhile in real life there's emails in real world that contain 0
+ // characters in encoded-text part. Probably makes sense to decode them anyway
+ Assert.assertEquals("", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?Q??="));
+ Assert.assertEquals("", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?B??="));
}
// see MIME4J-104
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org