This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 0b6ebe2907b7df5221bfb08fd1bfccd91032307e Author: Benoit Tellier <[email protected]> AuthorDate: Fri May 6 09:27:29 2022 +0700 [PERF] IMAP improve status items parsing Better handle closing bracket not to call substring. --- .../james/imap/decode/parser/StatusCommandParser.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/StatusCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/StatusCommandParser.java index 99bb000b93..5aa3b69403 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/StatusCommandParser.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/StatusCommandParser.java @@ -36,7 +36,6 @@ import org.apache.james.imap.message.request.StatusRequest; * Parse STATUS commands */ public class StatusCommandParser extends AbstractImapCommandParser { - private static final ImapRequestLineReader.NoopCharValidator NOOP_CHAR_VALIDATOR = new ImapRequestLineReader.NoopCharValidator(); public StatusCommandParser(StatusResponseFactory statusResponseFactory) { super(ImapConstants.STATUS_COMMAND, statusResponseFactory); @@ -59,20 +58,18 @@ public class StatusCommandParser extends AbstractImapCommandParser { request.nextWordChar(); request.consumeChar('('); - String nextWord = request.consumeWord(NOOP_CHAR_VALIDATOR); + request.nextWordChar(); - while (!nextWord.endsWith(")")) { - words.add(parseStatus(nextWord)); - nextWord = request.consumeWord(NOOP_CHAR_VALIDATOR); + while (request.nextChar() != ')') { + String nextWord = request.consumeWord(ImapRequestLineReader.NoopCharValidator.INSTANCE, true); if (nextWord.isEmpty()) { // Throw to avoid an infinite loop... throw new DecodingException(HumanReadableText.FAILED, "Empty word encountered"); } + words.add(parseStatus(nextWord)); + request.nextWordChar(); } - // Got the closing ")", may be attached to a word. - if (nextWord.length() > 1) { - words.add(parseStatus(nextWord.substring(0, nextWord.length() - 1))); - } + request.consumeChar(')'); return words; } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
