Hello Stuart,

I addressed this in git master by increasing the message limit in 
IMAPReply.UNTAGGED_RESPONSE from 160 to 500 characters.

See also snapshot builds in 
https://repository.apache.org/content/repositories/snapshots/

Gary

On 2024/08/26 16:57:59 Stuart Maclean wrote:
> I had found issue in Commons Net 3.11.0, whereby an 'untagged IMAP' 
> reply of sufficient length would cause a Pattern mismatch and the 
> following stack trace:
> 
> org.apache.commons.net.MalformedServerReplyException: Received
> 
> unexpected IMAP protocol response from server: '* OK The Microsoft
> Exchange IMAP4 service is ready. [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]'.
> at
> org.apache.commons.net.imap.IMAPReply.getReplyCode(IMAPReply.java:119)
> at
> org.apache.commons.net.imap.IMAPReply.getUntaggedReplyCode(IMAPReply.java:130)
> at org.apache.commons.net.imap.IMAP.getReply(IMAP.java:288)
> at org.apache.commons.net.imap.IMAP._connectAction_(IMAP.java:152)
> 
> This was apparently fixed in 3.11.1.
> 
> Browsing the latest source code, I see this regex
> 
>   private static final String UNTAGGED_RESPONSE = "^\\* 
> (\\S{1,80}).{0,160}";
> 
> If I am correct, this can match against a string of max length 240 chars ??
> 
> I am still seeing the error, even in 3.11.1.  Here is a recent example:
> 
> org.apache.commons.net.MalformedServerReplyException: Received 
> unexpected IMAP protocol response from server: '* OK The Microsoft 
> Exchange IMAP4 service is ready. 
> [TQBXADIAUABSADIAMQAwADEAQwBBADAAMAAzADYALgBuAGEAbQBwAHIAZAAyADEALgBwAHIAbwBkAC4AbwB1AHQAbABvAG8AawAuAGMAbwBtAA==]'.
>      at 
> org.apache.commons.net.imap.IMAPReply.getReplyCode(IMAPReply.java:119)
>      at 
> org.apache.commons.net.imap.IMAPReply.getUntaggedReplyCode(IMAPReply.java:130)
> 
> The string between the single quotes, which I suspect is the 'untagged 
> response', is 265 bytes in length, which is longer than the regex 
> definition.
> 
> Stuart
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to