]> git.kaiwu.me - nginx.git/commitdiff
Mail: stricter IMAP literals validation.
authorSergey Kandaurov <pluknet@nginx.com>
Fri, 27 Feb 2026 17:18:16 +0000 (21:18 +0400)
committerSergey Kandaurov <s.kandaurov@f5.com>
Wed, 4 Mar 2026 08:08:09 +0000 (12:08 +0400)
As clarified in RFC 3501, Section 7.5, literals are followed
either by SP, for additional command arguments, or CRLF.

src/mail/ngx_mail_parse.c

index 4db1f18d30e3482ac944a9709741c1804c033dc0..a694bf6b6064d0ce375adfb01f5e47a3b3614374 100644 (file)
@@ -598,20 +598,16 @@ ngx_mail_imap_parse_command(ngx_mail_session_t *s)
 
         case sw_end_literal_argument:
             switch (ch) {
-            case '{':
-                if (s->args.nelts <= 2) {
-                    state = sw_literal;
-                    break;
-                }
-                goto invalid;
+            case ' ':
+                state = sw_spaces_before_argument;
+                break;
             case CR:
                 state = sw_almost_done;
                 break;
             case LF:
                 goto done;
             default:
-                state = sw_spaces_before_argument;
-                break;
+                goto invalid;
             }
             break;