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 8889b9c307870604c2620d6cc9f4a8e3ee3a2c50 Author: Benoit Tellier <[email protected]> AuthorDate: Fri May 6 09:27:06 2022 +0700 [PERF] IMAP improve flags parsing Better handle closing bracket not to call substring. --- .../james/imap/decode/ImapRequestLineReader.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java index 9326f76ecc..9f96244d1b 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java @@ -516,24 +516,16 @@ public abstract class ImapRequestLineReader { Flags flags = new Flags(); nextWordChar(); consumeChar('('); - CharacterValidator validator = new NoopCharValidator(); - String nextWord = consumeWord(validator); - while (!nextWord.endsWith(")")) { - DecoderUtils.setFlag(nextWord, flags); - nextWord = consumeWord(validator); + while (nextChar() != ')') { + String nextWord = consumeWord(NoopCharValidator.INSTANCE, true); if (nextWord.isEmpty()) { // Throw to avoid an infinite loop... throw new DecodingException(HumanReadableText.FAILED, "Empty word encountered"); } + DecoderUtils.setFlag(nextWord, flags); + nextWordChar(); } - // Got the closing ")", may be attached to a word. - if (nextWord.length() > 1) { - int parenIndex = nextWord.indexOf(')'); - if (parenIndex > 0) { - final String nextFlag = nextWord.substring(0, parenIndex); - DecoderUtils.setFlag(nextFlag, flags); - } - } + consumeChar(')'); return flags; } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
