File: git_smtp_replies_with_3_chars.patch

package info (click to toggle)
sope 5.12.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 16,692 kB
  • sloc: objc: 169,218; sh: 3,823; ansic: 3,409; javascript: 446; python: 318; makefile: 185
file content (30 lines) | stat: -rw-r--r-- 1,147 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
commit 927aaeadcff6a55416e1ef29faa7bbe90d63daea
Author: Hivert Quentin <quentin.hivert.fr@gmail.com>
Date:   Tue Jun 17 15:28:53 2025 +0200

    fix(smtp): allow smtp replies with only 3 chars (being the number code) instead of 4 (code + space)

diff --git a/sope-mime/NGMail/NGSmtpClient.m b/sope-mime/NGMail/NGSmtpClient.m
index fa0cfb3..c6ec39f 100644
--- a/sope-mime/NGMail/NGSmtpClient.m
+++ b/sope-mime/NGMail/NGSmtpClient.m
@@ -478,6 +478,19 @@
   NGSmtpReplyCode code  = -1;
 
   line = [self->text readLineAsString];
+  if([line length] == 3) {
+    //Invalid but can happen with some smtp server that does not follow correctly the smtp specs
+    //and only send the code number instead of the code + a space.
+    code = [[line substringToIndex:3] intValue];
+    if(code == 0)
+    {
+      NSLog(@"SMTP: reply has invalid format and is not a code of 3 chars (%@)", line);
+      return nil;
+    }
+    desc = [NSMutableString stringWithCapacity:[line length]];
+    return [NGSmtpResponse responseWithCode:code text:desc];
+  }
+
   if ([line length] < 4) {
     NSLog(@"SMTP: reply has invalid format (%@)", line);
     return nil;