From: Cristy Date: Sat, 25 Aug 2018 19:33:36 +0000 (-0400) Subject: Fixed bug in {} globbing X-Git-Tag: 7.0.8-11~36 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=479c40bc59a7ab565fb08847e446a5578d5023c3;p=imagemagick Fixed bug in {} globbing --- diff --git a/MagickCore/token.c b/MagickCore/token.c index 4471a7d87..8c37a8544 100644 --- a/MagickCore/token.c +++ b/MagickCore/token.c @@ -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 '\\':