Permalink
Browse files

MIME4J-209: Regex pattern used by DecoderUtil disallowed question mar…

…k in the encoded text

git-svn-id: https://svn.apache.org/repos/asf/james/mime4j/trunk@1213804 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 28f70e8 commit 8ab9362b799f4fe44cb250bcd7a132f07dff8c40 @ok2c ok2c committed Dec 13, 2011
@@ -35,7 +35,7 @@
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.
@@ -107,6 +107,11 @@ public void testEncodedTextMayContainDollarSign() {
assertEquals("variable ${target.nl}", DecoderUtil.decodeEncodedWords("=?utf-8?Q?variable=20${target.nl}?="));
}
+ // see MIME4J-209
+ public void testEncodedTextMayContainQuestionMark() {
+ assertEquals("?", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?Q???="));
+ }
+
public void testNonWhiteSpaceBetweenEncodedWordsIsRetained() {
assertEquals("a b c", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?Q?a?= b =?ISO-8859-1?Q?c?="));
assertEquals("a\rb\nc", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?Q?a?=\rb\n=?ISO-8859-1?Q?c?="));

0 comments on commit 8ab9362

Please sign in to comment.