Commit a12d8ec55 for imagemagick.org

commit a12d8ec55fd9a69b9c5be751b00afbfac1e59a3b
Author: Cristy <urban-warrior@imagemagick.org>
Date:   Fri Dec 4 11:23:47 2026 -0500

    allowlist is now static const

diff --git a/MagickCore/delegate-private.h b/MagickCore/delegate-private.h
index 7ca393119..ab23cffae 100644
--- a/MagickCore/delegate-private.h
+++ b/MagickCore/delegate-private.h
@@ -81,33 +81,46 @@ typedef struct _GhostInfo
     (MagickDLLCall *revision)(gsapi_revision_t *, int);
 } GhostInfo;

-static inline char *SanitizeDelegateString(const char *source)
-{
-  char
-    *sanitize_source;
-
-  const char
-    *q;
-
-  char
-    *p;
+/*
+  Characters permitted in delegate command strings.
+*/
+#define DelegateAlphaNumeric \
+  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "

-  static char
 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
-    allowlist[] =
-      "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "
-      "$-_.+!;*(),{}|^~[]`\'><#%/?:@&=";
+# define DelegateAllowlist  DelegateAlphaNumeric "$-_.+!;*(),{}|^~[]`\'><#%/?:@&="
 #else
-    allowlist[] =
-      "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "
-      "$-_.+!;*(),{}|\\^~[]`\"><#%/?:@&=";
+# define DelegateAllowlist DelegateAlphaNumeric "$-_.+!;*(),{}|\\^~[]`\"><#%/?:@&="
 #endif

+static inline char *SanitizeDelegateString(const char *source)
+{
+  static const char
+    allowlist[] = DelegateAllowlist;
+
+  char
+    *p,
+    *sanitize_source;
+
+  /*
+    Returns a copy of source in which every character outside DelegateAllowlist is replaced
+    with '_'.
+  */
+  if (source == (const char *) NULL)
+    return(AcquireString(""));
   sanitize_source=AcquireString(source);
-  p=sanitize_source;
-  q=sanitize_source+strlen(sanitize_source);
-  for (p+=strspn(p,allowlist); p != q; p+=(ptrdiff_t) strspn(p,allowlist))
+  if (sanitize_source == (char *) NULL)
+    return((char *) NULL);
+  /*
+    Each pass skips a run of allowed characters; whatever stops the run is
+    disallowed (or the terminating NUL, which ends the loop).
+  */
+  p=sanitize_source+strspn(sanitize_source,allowlist);
+  while (*p != '\0')
+  {
     *p='_';
+    p+=strspn(p+1,allowlist)+1;
+  }
   return(sanitize_source);
 }