]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
test897: verify delivery of IMAP post-body header content
authorDaniel Stenberg <daniel@haxx.se>
Mon, 20 Sep 2021 08:33:26 +0000 (10:33 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 21 Sep 2021 06:18:42 +0000 (08:18 +0200)
The "content" is delivered as "body" by curl, but the envelope continues
after the body and the rest of it should be delivered as header.

The IMAP server can now get 'POSTFETCH' set to include more data to
include after the body and test 897 is done to verify that such "extra"
header data is in fact delivered by curl as header.

Ref: #7284 but fails to reproduce the issue

Closes #7748

tests/data/Makefile.inc
tests/data/test897 [new file with mode: 0644]
tests/ftpserver.pl

index 91b8c18ebcd1b057f74f0fc82f98e0d29d8b5131..1f774ce4e8b45d894d0b01307df00b6a095a10af 100644 (file)
@@ -106,7 +106,7 @@ test854 test855 test856 test857 test858 test859 test860 test861 test862 \
 test863 test864 test865 test866 test867 test868 test869 test870 test871 \
 test872 test873 test874 test875 test876 test877 test878 test879 test880 \
 test881 test882 test883 test884 test885 test886 test887 test888 test889 \
-test890 test891 test892 test893 test894 test895 test896 \
+test890 test891 test892 test893 test894 test895 test896 test897 \
 \
 test900 test901 test902 test903 test904 test905 test906 test907 test908 \
 test909 test910 test911 test912 test913 test914 test915 test916 test917 \
diff --git a/tests/data/test897 b/tests/data/test897
new file mode 100644 (file)
index 0000000..1a537ea
--- /dev/null
@@ -0,0 +1,70 @@
+<testcase>
+<info>
+<keywords>
+IMAP
+Clear Text
+FETCH
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data>
+body\r
+\r
+--\r
+  yours sincerely\r
+</data>
+<servercmd>
+POSTFETCH extra stuff sent in the envelope after the body
+</servercmd>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+imap
+</server>
+ <name>
+IMAP and envelope meta data after body transfer
+ </name>
+ <command>
+'imap://%HOSTIP:%IMAPPORT/%TESTNUMBER/;MAILINDEX=123/;SECTION=1' -u user:secret -D log/head-%TESTNUMBER
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+A001 CAPABILITY\r
+A002 LOGIN user secret\r
+A003 SELECT %TESTNUMBER\r
+A004 FETCH 123 BODY[1]\r
+A005 LOGOUT\r
+</protocol>
+<file name="log/head-%TESTNUMBER">
+        _   _ ____  _     \r
+    ___| | | |  _ \| |    \r
+   / __| | | | |_) | |    \r
+  | (__| |_| |  _ {| |___ \r
+   \___|\___/|_| \_\_____|\r
+* OK curl IMAP server ready to serve\r
+A001 BAD Command\r
+A002 OK LOGIN completed\r
+* 172 EXISTS\r
+* 1 RECENT\r
+* OK [UNSEEN 12] Message 12 is first unseen\r
+* OK [UIDVALIDITY 3857529045] UIDs valid\r
+* OK [UIDNEXT 4392] Predicted next UID\r
+* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)\r
+* OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited\r
+A003 OK [READ-WRITE] SELECT completed\r
+* 123 FETCH (BODY[1] {31}\r
+extra stuff sent in the envelope after the body)\r
+A004 OK FETCH completed\r
+</file>
+</verify>
+</testcase>
index a3819508a90f0135309f799d67330494e196ad32..b74ac5bb740f2f97650991eb5d30a0789ce9525d 100755 (executable)
@@ -146,6 +146,7 @@ my $nodataconn425; # set if ftp srvr doesn't establish data ch and replies 425
 my $nodataconn421; # set if ftp srvr doesn't establish data ch and replies 421
 my $nodataconn150; # set if ftp srvr doesn't establish data ch and replies 150
 my $storeresp;
+my $postfetch;
 my @capabilities;  # set if server supports capability commands
 my @auth_mechs;    # set if server supports authentication commands
 my %fulltextreply; #
@@ -1232,7 +1233,8 @@ sub FETCH_imap {
             sendcontrol $d;
         }
 
-        sendcontrol ")\r\n";
+        # Set the custom extra header content with POSTFETCH
+        sendcontrol "$postfetch)\r\n";
         sendcontrol "$cmdid OK FETCH completed\r\n";
     }
 
@@ -2798,6 +2800,7 @@ sub customize {
     $nodataconn421 = 0; # default is to not send 421 without data channel
     $nodataconn150 = 0; # default is to not send 150 without data channel
     $storeresp = "";    # send as ultimate STOR response
+    $postfetch = "";    # send as header after a FETCH response
     @capabilities = (); # default is to not support capability commands
     @auth_mechs = ();   # default is to not support authentication commands
     %fulltextreply = ();#
@@ -2840,6 +2843,10 @@ sub customize {
             $delayreply{$1}=$2;
             logmsg "FTPD: delay reply for $1 with $2 seconds\n";
         }
+        elsif($_ =~ /POSTFETCH (.*)/) {
+            logmsg "FTPD: read POSTFETCH header data\n";
+            $postfetch = $1;
+        }
         elsif($_ =~ /SLOWDOWN/) {
             $ctrldelay=1;
             $datadelay=1;