[
https://issues.apache.org/jira/browse/MIME4J-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12796164#action_12796164
]
Nevin commented on MIME4J-138:
------------------------------
There is an issue in the fix.
158 if ((!previousWasEncoded) ||
(!CharsetUtil.isWhitespace(separator)))
159 sb.append(separator);
160 matcher.appendReplacement(sb, decoded);
161 previousWasEncoded = true;
in funciton call matcher.appendReplacement( ), if the decoded contains "$", an
exception will be thrown:
java.lang.IllegalArgumentException: Illegal group reference
at java.util.regex.Matcher.appendReplacement(Matcher.java:706)
at
org.apache.james.mime4j.codec.DecoderUtil.decodeEncodedWords(DecoderUtil.java:160)
As described in java api doc, public Matcher appendReplacement(StringBuffer sb,
String replacement):
Note that backslashes (\) and dollar signs ($) in the replacement string
may cause the results to be different than if it were being treated as a
literal replacement string. Dollar signs may be treated as references to
captured subsequences as described above, and backslashes are used to escape
literal characters in the replacement string.
Here is the temporary fix between line 159 and line 150:
decoded = decoded.replace("\\", "\\\\");
decoded = decoded.replace("$", "\\$");
> DecoderUtil.decodeEncodedWords() fails if encoded-text starts with an equals
> sign
> ---------------------------------------------------------------------------------
>
> Key: MIME4J-138
> URL: https://issues.apache.org/jira/browse/MIME4J-138
> Project: JAMES Mime4j
> Issue Type: Bug
> Affects Versions: 0.6
> Reporter: Markus Wiederkehr
> Assignee: Markus Wiederkehr
> Fix For: 0.7
>
> Attachments: DecoderUtil.diff, DecoderUtil.java, mime4j-138.patch,
> RegexDecoderUtil.java
>
>
> For example "=?utf-8?Q?=20test?=" should be decoded as " test". Instead it
> does not get decoded at all.
> The problem is that DecoderUtil.decodeEncodedWords() falsely identifies
> =?utf-8?Q?= as the encoded word which cannot be decoded.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.