]> granicus.if.org Git - neomutt/commitdiff
fix: drop capability aliases
authorRichard Russon <rich@flatcap.org>
Wed, 1 Nov 2017 05:14:22 +0000 (05:14 +0000)
committerRichard Russon <rich@flatcap.org>
Wed, 8 Nov 2017 12:08:27 +0000 (12:08 +0000)
`CapabilityAliases` was a list of alternative names (just one) for IMAP
capability strings.  This isn't necessary.  We can put the strings in
`Capabilities` and fix the enumeration.

```c
enum ImapCaps
{
  ...
  X_GM_EXT1,
  X_GM_ALT1 = X_GM_EXT1,
  ...
};
```

imap/command.c
imap/imap_private.h

index 5bccd5a746f0ce1e7b55853b410085b13dba819a..02fe291360670a5fc15edd59fddc33a738eab2db 100644 (file)
  * Capabilities - Server capabilties strings that we understand
  *
  * @note This must be kept in the same order as ImapCaps.
+ *
+ * @note Gmail documents one string but use another, so we support both.
  */
 static const char *const Capabilities[] = {
   "IMAP4",     "IMAP4rev1",     "STATUS",      "ACL",
   "NAMESPACE", "AUTH=CRAM-MD5", "AUTH=GSSAPI", "AUTH=ANONYMOUS",
   "STARTTLS",  "LOGINDISABLED", "IDLE",        "SASL-IR",
-  "ENABLE",    "X-GM-EXT1",     NULL,
-};
-
-/**
- * struct CapabilityAlias - Alternative names for capabilities
- */
-struct CapabilityAlias
-{
-  char *name;
-  unsigned int value;
-};
-
-/**
- * CapabilityAliases - Alternate capability strings (for compatibility)
- */
-static struct CapabilityAlias CapabilityAliases[] = {
-  /* Gmail documents one string but use another.  Support both. */
-  { "X-GM-EXT-1", X_GM_EXT1 },
-  { NULL, 0 },
+  "ENABLE",    "X-GM-EXT1",     "X-GM-EXT-1",  NULL,
 };
 
 /**
@@ -387,7 +371,6 @@ static void cmd_parse_fetch(struct ImapData *idata, char *s)
  */
 static void cmd_parse_capability(struct ImapData *idata, char *s)
 {
-  bool found;
   char *bracket = NULL;
 
   mutt_debug(3, "Handling CAPABILITY\n");
@@ -402,30 +385,15 @@ static void cmd_parse_capability(struct ImapData *idata, char *s)
 
   while (*s)
   {
-    found = false;
     for (int i = 0; i < CAPMAX; i++)
     {
       if (imap_wordcasecmp(Capabilities[i], s) == 0)
       {
         mutt_bit_set(idata->capabilities, i);
         mutt_debug(4, " Found capability \"%s\": %d\n", Capabilities[i], i);
-        found = true;
         break;
       }
     }
-    if (!found)
-    {
-      for (int i = 0; CapabilityAliases[i].name != NULL; i++)
-      {
-        if (imap_wordcasecmp(CapabilityAliases[i].name, s) == 0)
-        {
-          mutt_bit_set(idata->capabilities, CapabilityAliases[i].value);
-          mutt_debug(4, " Found capability \"%s\": %d\n",
-                     CapabilityAliases[i].name, CapabilityAliases[i].value);
-          break;
-        }
-      }
-    }
     s = imap_next_word(s);
   }
 }
index 4bc51ea5b18af8bde7d25ff825d9f31948148bb1..15e4bd822d6bda913bb35c3cc6a457e60dcaaf5b 100644 (file)
@@ -136,6 +136,7 @@ enum ImapCaps
   SASL_IR,       /**< SASL initial response draft */
   ENABLE,        /**< RFC5161 */
   X_GM_EXT1,     /**< https://developers.google.com/gmail/imap/imap-extensions */
+  X_GM_ALT1 = X_GM_EXT1, /**< Alternative capability string */
 
   CAPMAX
 };