From 479c40bc59a7ab565fb08847e446a5578d5023c3 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 25 Aug 2018 15:33:36 -0400 Subject: [PATCH] Fixed bug in {} globbing --- MagickCore/token.c | 75 +++++++++++++++------------------------------- 1 file changed, 24 insertions(+), 51 deletions(-) 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 '\\': -- 2.40.0