Add RFC2047 tests and fix a resulting whitespace bug
This commit is contained in:
parent
0e9e4daa80
commit
498df5db73
2 changed files with 41 additions and 3 deletions
|
@ -161,7 +161,7 @@ class DecoderUtil {
|
|||
sb.append(body.substring(begin, end));
|
||||
previousWord = null;
|
||||
} else {
|
||||
sb.append(sep);
|
||||
// sb.append(sep);
|
||||
}
|
||||
} else {
|
||||
if (previousWord != null) {
|
||||
|
@ -169,11 +169,11 @@ class DecoderUtil {
|
|||
previousWord.encodedText += word.encodedText;
|
||||
} else {
|
||||
sb.append(decodeEncodedWord(previousWord));
|
||||
sb.append(sep);
|
||||
sb.append(sep.trim());
|
||||
previousWord = word;
|
||||
}
|
||||
} else {
|
||||
sb.append(sep);
|
||||
sb.append(sep.trim());
|
||||
previousWord = word;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,4 +194,42 @@ public class DecoderUtilTest {
|
|||
message = null;
|
||||
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeEncodedWords_withRFC2047examples_decodesCorrectly() {
|
||||
body = "(=?ISO-8859-1?Q?a?=)";
|
||||
expect = "(a)";
|
||||
message = null;
|
||||
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||
|
||||
body = "(=?ISO-8859-1?Q?a?= b)";
|
||||
expect = "(a b)";
|
||||
message = null;
|
||||
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||
|
||||
body = "(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)";
|
||||
expect = "(ab)";
|
||||
message = null;
|
||||
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||
|
||||
body = "(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)";
|
||||
expect = "(ab)";
|
||||
message = null;
|
||||
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||
|
||||
body = "(=?ISO-8859-1?Q?a?= \n =?ISO-8859-1?Q?b?=)";
|
||||
expect = "(ab)";
|
||||
message = null;
|
||||
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||
|
||||
body = "(=?ISO-8859-1?Q?a_b?=)";
|
||||
expect = "(a b)";
|
||||
message = null;
|
||||
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||
|
||||
body = "(=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=)";
|
||||
expect = "(a b)";
|
||||
message = null;
|
||||
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue