Repository: james-mime4j Updated Branches: refs/heads/master ae77907e3 -> 66a87ba9b
MIME4J-283 DecoderUtil performance fix Project: http://git-wip-us.apache.org/repos/asf/james-mime4j/repo Commit: http://git-wip-us.apache.org/repos/asf/james-mime4j/commit/66a87ba9 Tree: http://git-wip-us.apache.org/repos/asf/james-mime4j/tree/66a87ba9 Diff: http://git-wip-us.apache.org/repos/asf/james-mime4j/diff/66a87ba9 Branch: refs/heads/master Commit: 66a87ba9b1828b57618066ec682c8a11f34ad413 Parents: ae77907 Author: Dmitry Potapov <dpota...@yandex-team.ru> Authored: Fri Jan 18 18:17:43 2019 +0300 Committer: Benoit Tellier <btell...@linagora.com> Committed: Thu Jan 24 17:16:23 2019 +0700 ---------------------------------------------------------------------- .../org/apache/james/mime4j/codec/DecoderUtil.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-mime4j/blob/66a87ba9/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 dab1f20..ab4c9ee 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. @@ -178,17 +178,18 @@ public class DecoderUtil { StringBuilder sb = new StringBuilder(); for (Matcher matcher = PATTERN_ENCODED_WORD.matcher(body); matcher.find();) { - String separator = matcher.group(1); - String mimeCharset = matcher.group(2); - String encoding = matcher.group(3); - String encodedText = matcher.group(4); + String separator = body.substring(tailIndex, matcher.start()); + String mimeCharset = matcher.group(1); + String encoding = matcher.group(2); + String encodedText = matcher.group(3); - if ("".equals(encodedText)) + if (encodedText.isEmpty()) return ""; String decoded; decoded = tryDecodeEncodedWord(mimeCharset, encoding, encodedText, monitor, fallback); if (decoded == null) { + sb.append(separator); sb.append(matcher.group(0)); } else { if (!lastMatchValid || !CharsetUtil.isWhitespace(separator)) { --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org