]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
imap: simplify imap_is_bchar() with strchr()
authorDaniel Stenberg <daniel@haxx.se>
Mon, 19 Jan 2026 15:01:57 +0000 (16:01 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 19 Jan 2026 15:53:22 +0000 (16:53 +0100)
Closes #20358

lib/imap.c

index 7eb688074098b2d57e04ca875ba75ddfe3ff8107..3a73521ac6ed2eb8da713dfe8d04b997e5b3977d 100644 (file)
@@ -1677,40 +1677,9 @@ static void imap_easy_reset(struct IMAP *imap)
  */
 static bool imap_is_bchar(char ch)
 {
-  /* Performing the alnum check with this macro is faster because of ASCII
+  /* Performing the alnum check first with macro is faster because of ASCII
      arithmetic */
-  if(ISALNUM(ch))
-    return TRUE;
-
-  switch(ch) {
-  /* bchar */
-  case ':':
-  case '@':
-  case '/':
-  /* bchar -> achar */
-  case '&':
-  case '=':
-  /* bchar -> achar -> uchar -> unreserved (without alphanumeric) */
-  case '-':
-  case '.':
-  case '_':
-  case '~':
-  /* bchar -> achar -> uchar -> sub-delims-sh */
-  case '!':
-  case '$':
-  case '\'':
-  case '(':
-  case ')':
-  case '*':
-  case '+':
-  case ',':
-  /* bchar -> achar -> uchar -> pct-encoded */
-  case '%': /* HEXDIG chars are already included above */
-    return TRUE;
-
-  default:
-    return FALSE;
-  }
+  return ch && (ISALNUM(ch) || strchr(":@/&=-._~!$\'()*+,%", ch));
 }
 
 /***********************************************************************