]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
imap: change from "FETCH" to "UID FETCH"
authorNicklas Avén <nicklas.aven@jordogskog.no>
Tue, 31 Jul 2018 11:12:18 +0000 (13:12 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 6 Sep 2018 08:57:48 +0000 (10:57 +0200)
... and add "MAILINDEX".

As described in #2789, this is a suggested solution.  Changing UID=xx to
actually get mail with UID xx and add "MAILINDEX" to get a mail with a
special index in the mail box (old behavior).  So MAILINDEX=1 gives the
first non deleted mail in the mail box.

Fixes #2789
Closes #2815

40 files changed:
docs/libcurl/opts/CURLOPT_URL.3
lib/imap.c
lib/imap.h
tests/data/Makefile.inc
tests/data/test1321
tests/data/test1420
tests/data/test1552
tests/data/test800
tests/data/test801
tests/data/test802
tests/data/test803
tests/data/test804
tests/data/test819
tests/data/test820
tests/data/test821
tests/data/test822
tests/data/test823
tests/data/test824
tests/data/test825
tests/data/test826
tests/data/test827
tests/data/test828
tests/data/test830
tests/data/test831
tests/data/test832
tests/data/test833
tests/data/test834
tests/data/test835
tests/data/test836
tests/data/test837
tests/data/test838
tests/data/test839
tests/data/test840
tests/data/test842
tests/data/test843
tests/data/test844
tests/data/test845
tests/data/test846
tests/data/test847 [new file with mode: 0644]
tests/ftpserver.pl

index 52ff9c6d76fb9e17c0e9f3a44f0899da2c66c64d..60308cbceea82ad640b9e9bdaa6b7daf372f749c 100644 (file)
@@ -187,7 +187,10 @@ imap://user:password@mail.example.com/INBOX - Performs a folder list on the
 user's inbox
 
 imap://user:password@mail.example.com/INBOX/;UID=1 - Selects the user's inbox
-and fetches message 1
+and fetches message with uid = 1
+
+imap://user:password@mail.example.com/INBOX/;MAILINDEX=1 - Selects the user's inbox
+and fetches the first message in the mail box
 
 imap://user:password@mail.example.com/INBOX;UIDVALIDITY=50/;UID=2 - Selects
 the user's inbox, checks the UIDVALIDITY of the mailbox is 50 and fetches
index 942fe7d1efc4e766d6d849074c677249e6f1d18f..4a9c01ae7536bd55f2b14115e40c01e66f1c9ab6 100644 (file)
@@ -421,7 +421,6 @@ static CURLcode imap_perform_capability(struct connectdata *conn)
 {
   CURLcode result = CURLE_OK;
   struct imap_conn *imapc = &conn->proto.imapc;
-
   imapc->sasl.authmechs = SASL_AUTH_NONE; /* No known auth. mechanisms yet */
   imapc->sasl.authused = SASL_AUTH_NONE;  /* Clear the auth. mechanism used */
   imapc->tls_supported = FALSE;           /* Clear the TLS capability */
@@ -683,24 +682,37 @@ static CURLcode imap_perform_fetch(struct connectdata *conn)
 {
   CURLcode result = CURLE_OK;
   struct IMAP *imap = conn->data->req.protop;
-
   /* Check we have a UID */
-  if(!imap->uid) {
-    failf(conn->data, "Cannot FETCH without a UID.");
-    return CURLE_URL_MALFORMAT;
+  if(imap->uid) {
+
+    /* Send the FETCH command */
+    if(imap->partial)
+      result = imap_sendf(conn, "UID FETCH %s BODY[%s]<%s>",
+                            imap->uid,
+                            imap->section ? imap->section : "",
+                            imap->partial);
+    else
+      result = imap_sendf(conn, "UID FETCH %s BODY[%s]",
+                            imap->uid,
+                            imap->section ? imap->section : "");
+  }
+  else if(imap->mindex) {
+
+    /* Send the FETCH command */
+    if(imap->partial)
+      result = imap_sendf(conn, "FETCH %s BODY[%s]<%s>",
+                            imap->mindex,
+                            imap->section ? imap->section : "",
+                            imap->partial);
+    else
+      result = imap_sendf(conn, "FETCH %s BODY[%s]",
+                            imap->mindex,
+                            imap->section ? imap->section : "");
+  }
+  else {
+        failf(conn->data, "Cannot FETCH without a UID.");
+        return CURLE_URL_MALFORMAT;
   }
-
-  /* Send the FETCH command */
-  if(imap->partial)
-    result = imap_sendf(conn, "FETCH %s BODY[%s]<%s>",
-                        imap->uid,
-                        imap->section ? imap->section : "",
-                        imap->partial);
-  else
-    result = imap_sendf(conn, "FETCH %s BODY[%s]",
-                        imap->uid,
-                        imap->section ? imap->section : "");
-
   if(!result)
     state(conn, IMAP_FETCH);
 
@@ -1464,9 +1476,10 @@ static CURLcode imap_done(struct connectdata *conn, CURLcode status,
     result = status;         /* use the already set error code */
   }
   else if(!data->set.connect_only && !imap->custom &&
-          (imap->uid || data->set.upload ||
+          (imap->uid || imap->mindex || data->set.upload ||
           data->set.mimepost.kind != MIMEKIND_NONE)) {
     /* Handle responses after FETCH or APPEND transfer has finished */
+
     if(!data->set.upload && data->set.mimepost.kind == MIMEKIND_NONE)
       state(conn, IMAP_FETCH_FINAL);
     else {
@@ -1490,6 +1503,7 @@ static CURLcode imap_done(struct connectdata *conn, CURLcode status,
   Curl_safefree(imap->mailbox);
   Curl_safefree(imap->uidvalidity);
   Curl_safefree(imap->uid);
+  Curl_safefree(imap->mindex);
   Curl_safefree(imap->section);
   Curl_safefree(imap->partial);
   Curl_safefree(imap->query);
@@ -1543,14 +1557,14 @@ static CURLcode imap_perform(struct connectdata *conn, bool *connected,
   else if(imap->custom && (selected || !imap->mailbox))
     /* Custom command using the same mailbox or no mailbox */
     result = imap_perform_list(conn);
-  else if(!imap->custom && selected && imap->uid)
+  else if(!imap->custom && selected && (imap->uid || imap->mindex))
     /* FETCH from the same mailbox */
     result = imap_perform_fetch(conn);
   else if(!imap->custom && selected && imap->query)
     /* SEARCH the current mailbox */
     result = imap_perform_search(conn);
   else if(imap->mailbox && !selected &&
-         (imap->custom || imap->uid || imap->query))
+         (imap->custom || imap->uid || imap->mindex || imap->query))
     /* SELECT the mailbox */
     result = imap_perform_select(conn);
   else
@@ -2016,6 +2030,13 @@ static CURLcode imap_parse_url_path(struct connectdata *conn)
       imap->uid = value;
       value = NULL;
     }
+    else if(strcasecompare(name, "MAILINDEX") && !imap->mindex) {
+      if(valuelen > 0 && value[valuelen - 1] == '/')
+        value[valuelen - 1] = '\0';
+
+      imap->mindex = value;
+      value = NULL;
+    }
     else if(strcasecompare(name, "SECTION") && !imap->section) {
       if(valuelen > 0 && value[valuelen - 1] == '/')
         value[valuelen - 1] = '\0';
@@ -2043,7 +2064,7 @@ static CURLcode imap_parse_url_path(struct connectdata *conn)
 
   /* Does the URL contain a query parameter? Only valid when we have a mailbox
      and no UID as per RFC-5092 */
-  if(imap->mailbox && !imap->uid && *ptr == '?') {
+  if(imap->mailbox && !imap->uid && !imap->mindex && *ptr == '?') {
     /* Find the length of the query parameter */
     begin = ++ptr;
     while(imap_is_bchar(*ptr))
index 9fc4ff5a3daa315f7862d776c6bdece8786c82c8..0efcfd293cc77aca658b3c3524c8df1dd9639725 100644 (file)
@@ -58,6 +58,7 @@ struct IMAP {
   char *mailbox;          /* Mailbox to select */
   char *uidvalidity;      /* UIDVALIDITY to check in select */
   char *uid;              /* Message UID to fetch */
+  char *mindex;           /* Index in mail box of mail to fetch */
   char *section;          /* Message SECTION to fetch */
   char *partial;          /* Message PARTIAL to fetch */
   char *query;            /* Query to search for */
index 0980ff0032737e32b376d804b925338bb01b908f..aa0b03e3cdcb15470822afb6c5b86d91ccb71244 100644 (file)
@@ -93,7 +93,7 @@ test809 test810 test811 test812 test813 test814 test815 test816 test817 \
 test818 test819 test820 test821 test822 test823 test824 test825 test826 \
 test827 test828 test829 test830 test831 test832 test833 test834 test835 \
 test836 test837 test838 test839 test840 test841 test842 test843 test844 \
-test845 test846 \
+test845 test846 test847 \
 \
 test850 test851 test852 test853 test854 test855 test856 test857 test858 \
 test859 test860 test861 test862 test863 test864 test865 test866 test867 \
index ee1b47857f488ca917e0c2622107956666c4a62c..72a52c9357d109eb1745bf1a673fa1f8db0e01f6 100644 (file)
@@ -51,7 +51,7 @@ http
 IMAP FETCH tunneled through HTTP proxy
  </name>
  <command>
-'imap://imap.1321:%IMAPPORT/1321/;UID=1' -u user:secret -p -x %HOSTIP:%PROXYPORT
+'imap://imap.1321:%IMAPPORT/1321/;MAILINDEX=1' -u user:secret -p -x %HOSTIP:%PROXYPORT
 </command>
 </client>
 
index a5e1c5214194f87b1a6087a6e256a1ee4c479bfc..081ac6bbb6b1dbb54de6944b34e7b0fdec52d751 100644 (file)
@@ -36,7 +36,7 @@ imap
 SSL_CERT_FILE=
 </setenv>
 <command>
-'imap://%HOSTIP:%IMAPPORT/1420/;UID=1' -u user:secret --libcurl log/test1420.c
+'imap://%HOSTIP:%IMAPPORT/1420/;MAILINDEX=1' -u user:secret --libcurl log/test1420.c
 </command>
 </client>
 
@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
 
   hnd = curl_easy_init();
   curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
-  curl_easy_setopt(hnd, CURLOPT_URL, "imap://%HOSTIP:%IMAPPORT/1420/;UID=1");
+  curl_easy_setopt(hnd, CURLOPT_URL, "imap://%HOSTIP:%IMAPPORT/1420/;MAILINDEX=1");
   curl_easy_setopt(hnd, CURLOPT_USERPWD, "user:secret");
   curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
   curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
index c5b1b57284c1102d49eab2b6c44fd85fc1f28d6d..48e55cb514c194c6afe7c262873a34d39f195d72 100644 (file)
@@ -39,7 +39,7 @@ IMAP multi transfer error without curl_multi_remove_handle
 lib1552
 </tool>
  <command>
-'imap://%HOSTIP:%IMAPPORT/1552/;UID=1'
+'imap://%HOSTIP:%IMAPPORT/1552/;MAILINDEX=1'
 </command>
 </client>
 
index 360206b43d7947b65fd74e1d01d3884a9da235fe..6b74da90fec210f989f1113e04d48668906690c6 100644 (file)
@@ -31,7 +31,7 @@ imap
 IMAP FETCH message
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/800/;UID=1' -u '"user:sec"ret{'
+'imap://%HOSTIP:%IMAPPORT/800/;MAILINDEX=1' -u '"user:sec"ret{'
 </command>
 </client>
 
index 0012d3e4d2d11cb2fc724a2cea455678323357e5..90766f79fd115da4a5fda571a2eabb53fa5e662a 100644 (file)
@@ -25,10 +25,10 @@ body
 imap
 </server>
  <name>
-IMAP FETCH message by UID and SECTION
+IMAP FETCH message by MAILINDEX and SECTION
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/801/;UID=123/;SECTION=1' -u user:secret
+'imap://%HOSTIP:%IMAPPORT/801/;MAILINDEX=123/;SECTION=1' -u user:secret
 </command>
 </client>
 
index 17349a89a8f29bc37230a2de5b098f305db54019..19206a75da12511ab362f810b6bc9ea7a6574ff8 100644 (file)
@@ -29,7 +29,7 @@ imap
 IMAP SELECT UIDVALIDITY Success
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/802;UIDVALIDITY=3857529045/;UID=123/;SECTION=TEXT' -u user:secret
+'imap://%HOSTIP:%IMAPPORT/802;UIDVALIDITY=3857529045/;MAILINDEX=123/;SECTION=TEXT' -u user:secret
 </command>
 </client>
 
index 5b8cc9eb6419c010c6161b1bfc45c9233b544a65..834e4211d20079d15c42aac2f0db67b68cfc6f80 100644 (file)
@@ -24,7 +24,7 @@ imap
 IMAP SELECT UIDVALIDITY Failure
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/803;UIDVALIDITY=12345/;UID=123' -u user:secret
+'imap://%HOSTIP:%IMAPPORT/803;UIDVALIDITY=12345/;MAILINDEX=123' -u user:secret
 </command>
 </client>
 
index c6dfccf4a9dab94106b77045f686776cfd04f417..90635c22cc4832db6b75ab6d4e0af0af0184378d 100644 (file)
@@ -28,7 +28,7 @@ imap
 IMAP doesn't perform SELECT if re-using the same mailbox
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/804/;UID=123/;SECTION=1' 'imap://%HOSTIP:%IMAPPORT/804/;UID=456/;SECTION=2.3' -u user:secret
+'imap://%HOSTIP:%IMAPPORT/804/;MAILINDEX=123/;SECTION=1' 'imap://%HOSTIP:%IMAPPORT/804/;MAILINDEX=456/;SECTION=2.3' -u user:secret
 </command>
 </client>
 
index d0aa47ba549f3be010b399e0d244c51edfeb2524..b88e350559eb97f957dc34bd8f94476c7ae0ba98 100644 (file)
@@ -37,7 +37,7 @@ imap
 IMAP plain authentication
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/819/;UID=1' -u user:secret
+'imap://%HOSTIP:%IMAPPORT/819/;MAILINDEX=1' -u user:secret
 </command>
 </client>
 
index f638f1cb63355e87ab029b7571f6590740b15f2f..0fe9bf2d6914526f9a99a96f818e133eb9a40010 100644 (file)
@@ -37,7 +37,7 @@ imap
 IMAP login authentication
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/820/;UID=1' -u user:secret
+'imap://%HOSTIP:%IMAPPORT/820/;MAILINDEX=1' -u user:secret
 </command>
 </client>
 
index aee373b9a36dbe35b96d06f9f04ec7a80be816b7..6c511c1ef3217002d7ecb1c874d65bf464ae0833 100644 (file)
@@ -40,7 +40,7 @@ crypto
 IMAP CRAM-MD5 authentication
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/821/;UID=1' -u user:secret
+'imap://%HOSTIP:%IMAPPORT/821/;MAILINDEX=1' -u user:secret
 </command>
 </client>
 
index a6c0407e6000d030191bb6dd17fd27f79c3770e1..60f0cf1d39aa9ebc34988c007582b2c189930428 100644 (file)
@@ -48,7 +48,7 @@ CURL_GETHOSTNAME=curlhost
 LD_PRELOAD=%PWD/libtest/.libs/libhostname.so
  </setenv>
  <command>
-'imap://%HOSTIP:%IMAPPORT/822/;UID=1' -u testuser:testpass
+'imap://%HOSTIP:%IMAPPORT/822/;MAILINDEX=1' -u testuser:testpass
 </command>
 <precheck>
 chkhostname curlhost
index 25c59ec608e3a4b92113f4ccf696300c9c78f89b..32bd9d18978970cc890a0e08420125dbfba0205c 100644 (file)
@@ -43,7 +43,7 @@ crypto
 IMAP DIGEST-MD5 authentication
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/823/;UID=1' -u user:secret
+'imap://%HOSTIP:%IMAPPORT/823/;MAILINDEX=1' -u user:secret
 </command>
 </client>
 
index e646eec7644d78f601e0e1ee71c884f4f84de1d2..96c8e87b9999e1dfca86a2161db8402a70dfa704 100644 (file)
@@ -37,7 +37,7 @@ imap
 IMAP OAuth 2.0 (XOAUTH2) authentication
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/824/;UID=1' -u user --oauth2-bearer mF_9.B5f-4.1JqM
+'imap://%HOSTIP:%IMAPPORT/824/;MAILINDEX=1' -u user --oauth2-bearer mF_9.B5f-4.1JqM
 </command>
 </client>
 
index 6532b3ace7ef53e12dbde7dc95944a567a605d50..b489e95de6683d8bb94ba0ae28fc3ef56fa1fb51 100644 (file)
@@ -38,7 +38,7 @@ imap
 IMAP plain authentication with initial response
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/825/;UID=1' -u user:secret
+'imap://%HOSTIP:%IMAPPORT/825/;MAILINDEX=1' -u user:secret
 </command>
 </client>
 
index 0f9282945f2a3c84ff1d5865c12f4c205e4b735d..a1125e2f40ce974f489a0975106d08ee4f8bf5c6 100644 (file)
@@ -38,7 +38,7 @@ imap
 IMAP login authentication with initial response
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/826/;UID=1' -u user:secret
+'imap://%HOSTIP:%IMAPPORT/826/;MAILINDEX=1' -u user:secret
 </command>
 </client>
 
index 5005271e1590ac0254105a86f4608620180c9ad6..1329ed2378993de48c3e2219f1f8b271575aaac8 100644 (file)
@@ -49,7 +49,7 @@ CURL_GETHOSTNAME=curlhost
 LD_PRELOAD=%PWD/libtest/.libs/libhostname.so
  </setenv>
  <command>
-'imap://%HOSTIP:%IMAPPORT/827/;UID=1' -u testuser:testpass
+'imap://%HOSTIP:%IMAPPORT/827/;MAILINDEX=1' -u testuser:testpass
 </command>
 <precheck>
 chkhostname curlhost
index c86516a60e8201e49d88214719e7f5a00f768cc3..912aeff3d805f18a8af063ba07f47ebfff809f0a 100644 (file)
@@ -38,7 +38,7 @@ imap
 IMAP OAuth 2.0 (XOAUTH2) authentication with initial response
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/828/;UID=1' -u user --oauth2-bearer mF_9.B5f-4.1JqM
+'imap://%HOSTIP:%IMAPPORT/828/;MAILINDEX=1' -u user --oauth2-bearer mF_9.B5f-4.1JqM
 </command>
 </client>
 
index 5803bb11ed60d94fdc360161fdba164c53e89a40..c7812b7944813f0ff501c028ec638b4dfe294383 100644 (file)
@@ -33,7 +33,7 @@ crypto
 IMAP CRAM-MD5 graceful cancellation
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/830/;UID=1' -u user:secret
+'imap://%HOSTIP:%IMAPPORT/830/;MAILINDEX=1' -u user:secret
 </command>
 </client>
 
index 8bff7eac0ff863d670225067d3f0062af76d0156..fdcae29c145c0fea7296409fd55d96d03fcf0f10 100644 (file)
@@ -40,7 +40,7 @@ CURL_GETHOSTNAME=curlhost
 LD_PRELOAD=%PWD/libtest/.libs/libhostname.so
  </setenv>
  <command>
-'imap://%HOSTIP:%IMAPPORT/831/;UID=1' -u testuser:testpass
+'imap://%HOSTIP:%IMAPPORT/831/;MAILINDEX=1' -u testuser:testpass
 </command>
 <precheck>
 chkhostname curlhost
index 044edb1926f9cda69e454361e00bc0e06c9c2403..360654ab032218055d05372641078cc92acaa829 100644 (file)
@@ -35,7 +35,7 @@ crypto
 IMAP DIGEST-MD5 graceful cancellation
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/832/;UID=1' -u user:secret
+'imap://%HOSTIP:%IMAPPORT/832/;MAILINDEX=1' -u user:secret
 </command>
 </client>
 
index b5fa03f9e078c272fae8c1520a475dbecd76768c..dc8214b8ec80c16d7813c6c003c4b764bb3fb414 100644 (file)
@@ -44,7 +44,7 @@ crypto
 IMAP CRAM-MD5 authentication with SASL downgrade
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/833/;UID=1' -u user:secret
+'imap://%HOSTIP:%IMAPPORT/833/;MAILINDEX=1' -u user:secret
 </command>
 </client>
 
index 17101ddfcf90ca995bce183daab4da717f564c14..fc131773b68f015e65f864a78cf42fa124234874 100644 (file)
@@ -51,7 +51,7 @@ CURL_GETHOSTNAME=curlhost
 LD_PRELOAD=%PWD/libtest/.libs/libhostname.so
  </setenv>
  <command>
-'imap://%HOSTIP:%IMAPPORT/834/;UID=1' -u user:secret
+'imap://%HOSTIP:%IMAPPORT/834/;MAILINDEX=1' -u user:secret
 </command>
 <precheck>
 chkhostname curlhost
index 34f28b71b20de62f9f69c02333cc208812b86a53..400233c0cb5c494fd4f92e3c723917e4cd225503 100644 (file)
@@ -46,7 +46,7 @@ crypto
 IMAP DIGEST-MD5 authentication with SASL downgrade
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/835/;UID=1' -u user:secret
+'imap://%HOSTIP:%IMAPPORT/835/;MAILINDEX=1' -u user:secret
 </command>
 </client>
 
index 035d48ffe8aba84126ba2f3d3020ce3f91c078be..9478042ed9744407eecefcb5f8670a52d3b58314 100644 (file)
@@ -36,7 +36,7 @@ imap
 IMAP multiple connection authentication
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/836/;UID=1' -u user.one:secret -: 'imap://%HOSTIP:%IMAPPORT/836/;UID=2' -u user.two:secret
+'imap://%HOSTIP:%IMAPPORT/836/;MAILINDEX=1' -u user.one:secret -: 'imap://%HOSTIP:%IMAPPORT/836/;UID=2' -u user.two:secret
 </command>
 </client>
 
index d5974634e62505616c328d0d6dcc569118d54797..032726681a6287c411d4d8752d9111277aa8c4ad 100644 (file)
@@ -37,7 +37,7 @@ imap
 IMAP external authentication
  </name>
  <command>
-'imap://user;AUTH=EXTERNAL@%HOSTIP:%IMAPPORT/837/;UID=1'
+'imap://user;AUTH=EXTERNAL@%HOSTIP:%IMAPPORT/837/;MAILINDEX=1'
 </command>
 </client>
 
index da2d28d050160fa9c7437d2026736608ef031fbc..f5378fb4009fbc4146e219c4ae05f15023817712 100644 (file)
@@ -37,7 +37,7 @@ imap
 IMAP external authentication without credentials
  </name>
  <command>
-'imap://;AUTH=EXTERNAL@%HOSTIP:%IMAPPORT/838/;UID=1'
+'imap://;AUTH=EXTERNAL@%HOSTIP:%IMAPPORT/838/;MAILINDEX=1'
 </command>
 </client>
 
index 2a544c1cfcf826188a167600226f6c1dce94ade0..508fb8e5723ddb30c391c350ecfa10c0709315db 100644 (file)
@@ -38,7 +38,7 @@ imap
 IMAP external authentication with initial response
  </name>
  <command>
-'imap://user;AUTH=EXTERNAL@%HOSTIP:%IMAPPORT/839/;UID=1'
+'imap://user;AUTH=EXTERNAL@%HOSTIP:%IMAPPORT/839/;MAILINDEX=1'
 </command>
 </client>
 
index eaf1aeea4a1c078175ae5a60aab426e1a83a84b8..1e85af396b2930da51067e9cdbf7745222d6b383 100644 (file)
@@ -38,7 +38,7 @@ imap
 IMAP external authentication with initial response without credentials
  </name>
  <command>
-'imap://;AUTH=EXTERNAL@%HOSTIP:%IMAPPORT/840/;UID=1'
+'imap://;AUTH=EXTERNAL@%HOSTIP:%IMAPPORT/840/;MAILINDEX=1'
 </command>
 </client>
 
index d5aabbca82a99dd44c4ec1eeb65c0b74457718f9..e86abd430faaddd9d63fa88734e4e350cd42fca7 100644 (file)
@@ -38,7 +38,7 @@ imap
 IMAP OAuth 2.0 (OAUTHBEARER) authentication
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/842/;UID=1' -u user --oauth2-bearer mF_9.B5f-4.1JqM
+'imap://%HOSTIP:%IMAPPORT/842/;MAILINDEX=1' -u user --oauth2-bearer mF_9.B5f-4.1JqM
 </command>
 # The protocol section doesn't support ways of specifying the raw data in the
 # base64 encoded message so we must assert this
index a1c31a4549b04c2f5d13708e8584ae3e9e6438ca..e286fd93fc5f88ad8a44702d55a9151cb2c17ac8 100644 (file)
@@ -39,7 +39,7 @@ imap
 IMAP OAuth 2.0 (OAUTHBEARER) authentication with initial response
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/843/;UID=1' -u user --oauth2-bearer mF_9.B5f-4.1JqM
+'imap://%HOSTIP:%IMAPPORT/843/;MAILINDEX=1' -u user --oauth2-bearer mF_9.B5f-4.1JqM
 </command>
 # The protocol section doesn't support ways of specifying the raw data in the
 # base64 encoded message so we must assert this
index 055a9d2f4ab5f1573e14722f047960aff31d86d7..2cdb265fa3fc50237137eb2722df5880445b198a 100644 (file)
@@ -30,7 +30,7 @@ imap
 IMAP OAuth 2.0 (OAUTHBEARER) failure as continuation
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/844/;UID=1' -u user --oauth2-bearer mF_9.B5f-4.1JqM
+'imap://%HOSTIP:%IMAPPORT/844/;MAILINDEX=1' -u user --oauth2-bearer mF_9.B5f-4.1JqM
 </command>
 # The protocol section doesn't support ways of specifying the raw data in the
 # base64 encoded message so we must assert this
index e23b3d69e83311fa1fd5da663a1129a45862cfd2..d8b55748853644c07ab4e0917651963a2efe4be5 100644 (file)
@@ -31,7 +31,7 @@ imap
 IMAP OAuth 2.0 (OAUTHBEARER) failure as continuation with initial response
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/845/;UID=1' -u user --oauth2-bearer mF_9.B5f-4.1JqM
+'imap://%HOSTIP:%IMAPPORT/845/;MAILINDEX=1' -u user --oauth2-bearer mF_9.B5f-4.1JqM
 </command>
 # The protocol section doesn't support ways of specifying the raw data in the
 # base64 encoded message so we must assert this
index b363ffd18a9a54488853a3d1c3f9b25dd4267705..8d4d3c5fcf6ba040d79e7ed7895d3e65342dfa33 100644 (file)
@@ -33,7 +33,7 @@ imap
 IMAP PREAUTH response
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/846/;UID=1' -u notused:still-provided
+'imap://%HOSTIP:%IMAPPORT/846/;MAILINDEX=1' -u notused:still-provided
 </command>
 </client>
 
diff --git a/tests/data/test847 b/tests/data/test847
new file mode 100644 (file)
index 0000000..d4c1043
--- /dev/null
@@ -0,0 +1,49 @@
+<testcase>
+<info>
+<keywords>
+IMAP
+Clear Text
+FETCH
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data>
+From: me@somewhere\r
+To: fake@nowhere\r
+\r
+body\r
+\r
+--\r
+  yours sincerely\r
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+imap
+</server>
+ <name>
+IMAP FETCH message
+ </name>
+ <command>
+'imap://%HOSTIP:%IMAPPORT/847/;UID=1' -u '"user:sec"ret{'
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+A001 CAPABILITY\r
+A002 LOGIN "\"user" "sec\"ret{"\r
+A003 SELECT 847\r
+A004 UID FETCH 1 BODY[]\r
+A005 LOGOUT\r
+</protocol>
+</verify>
+</testcase>
index 97f7b8ea5ead66da8636927968b98f1b48144e10..d401be24ca65f98906182d92d6c76e7c9d4d3f48 100755 (executable)
@@ -1560,7 +1560,13 @@ sub UID_imap {
     if ($selected eq "") {
         sendcontrol "$cmdid BAD Command received in Invalid state\r\n";
     }
-    elsif (($command ne "COPY") && ($command ne "FETCH") &&
+    elsif (substr($command, 0, 5) eq "FETCH"){
+        my $func = $commandfunc{"FETCH"};
+        if($func) {
+            &$func($args, $command);
+        }
+    }
+    elsif (($command ne "COPY") &&
            ($command ne "STORE") && ($command ne "SEARCH")) {
         sendcontrol "$cmdid BAD Command Argument\r\n";
     }