]> granicus.if.org Git - imagemagick/commitdiff
Fixed bug in {} globbing
authorCristy <urban-warrior@imagemagick.org>
Sat, 25 Aug 2018 19:33:36 +0000 (15:33 -0400)
committerCristy <urban-warrior@imagemagick.org>
Sat, 25 Aug 2018 19:33:36 +0000 (15:33 -0400)
MagickCore/token.c

index 4471a7d87dca4a7cf6767efc1b069cf277813692..8c37a854422c323fa8baa8f5a7af3ae5a4981047 100644 (file)
@@ -504,62 +504,35 @@ MagickExport MagickBooleanType GlobExpression(const char *expression,
       }
       case '{':
       {
-        pattern+=GetUTFOctets(pattern);
+        char
+          *target;
+
+        register char
+          *p;
+
+        target=AcquireString(pattern);
+        p=target;
         while ((GetUTFCode(pattern) != '}') && (GetUTFCode(pattern) != 0))
         {
-          p=expression;
-          match=MagickTrue;
-          while ((GetUTFCode(p) != 0) && (GetUTFCode(pattern) != 0) &&
-                 (GetUTFCode(pattern) != ',') && (GetUTFCode(pattern) != '}') &&
-                 (match != MagickFalse))
-          {
-            if (GetUTFCode(pattern) == '\\')
-              pattern+=GetUTFOctets(pattern);
-            match=(GetUTFCode(pattern) == GetUTFCode(p)) ? MagickTrue :
-              MagickFalse;
-            p+=GetUTFOctets(p);
-            pattern+=GetUTFOctets(pattern);
-          }
-          if (GetUTFCode(pattern) == 0)
+          *p++=(*pattern++);
+          if ((GetUTFCode(pattern) == ',') || (GetUTFCode(pattern) == '}'))
             {
-              match=MagickFalse;
-              done=MagickTrue;
-              break;
-            }
-          if (match != MagickFalse)
-            {
-              expression=p;
-              while ((GetUTFCode(pattern) != '}') &&
-                     (GetUTFCode(pattern) != 0))
-              {
-                pattern+=GetUTFOctets(pattern);
-                if (GetUTFCode(pattern) == '\\')
-                  {
-                    pattern+=GetUTFOctets(pattern);
-                    if (GetUTFCode(pattern) == '}')
-                      pattern+=GetUTFOctets(pattern);
-                  }
-              }
-            }
-          else
-            {
-              while ((GetUTFCode(pattern) != '}') &&
-                     (GetUTFCode(pattern) != ',') &&
-                     (GetUTFCode(pattern) != 0))
-              {
-                pattern+=GetUTFOctets(pattern);
-                if (GetUTFCode(pattern) == '\\')
-                  {
-                    pattern+=GetUTFOctets(pattern);
-                    if ((GetUTFCode(pattern) == '}') ||
-                        (GetUTFCode(pattern) == ','))
-                      pattern+=GetUTFOctets(pattern);
-                  }
-              }
+              *p='\0';
+              match=GlobExpression(expression,target,case_insensitive);
+              if (match != MagickFalse)
+                {
+                  expression+=strlen(target);
+                  break;
+                }
+              p=target;
+              pattern+=GetUTFOctets(pattern);
             }
-          if (GetUTFCode(pattern) != 0)
-            pattern+=GetUTFOctets(pattern);
         }
+        while ((GetUTFCode(pattern) != '}') && (GetUTFCode(pattern) != 0))
+          pattern+=GetUTFOctets(pattern);
+        if (GetUTFCode(pattern) != 0)
+          pattern+=GetUTFOctets(pattern);
+        target=DestroyString(target);
         break;
       }
       case '\\':