Page 1 of 1

Backslash escaping in GlobExpression()

Posted: 2010-04-22T05:17:38-07:00
by tstarling
Backslash escaping is completely broken in GlobExpression(). I have confirmed this in IM 6.5.1 (from Ubuntu) and I have read the code in trunk which strongly suggests that this bug continues up to the current HEAD. There is code there, but all it does is removes the character following the backslash from the pattern, it doesn't do a literal match. So this:

image\a\b\*.png

matches this:

image.png

which is presumably not intended.

This means that it is virtually impossible to process a file with a literal asterisk in its name with the convert command. Of course, any seasoned UNIX hacker knows that you shouldn't use asterisks in filenames, but our users are not universally such, and this is not a restriction we want to impose on them unless it's really necessary.

Re: Backslash escaping in GlobExpression()

Posted: 2010-04-22T05:28:47-07:00
by magick
We will investigate and get a patch for this problem in ImageMagick 6.6.1-5 Beta within the next day or two. Thanks,

Re: Backslash escaping in GlobExpression()

Posted: 2010-04-23T08:41:34-07:00
by tstarling
I see you committed a fix in r1719. The fix doesn't appear to work, I assume you didn't test it. May I suggest additionally applying something along the lines of the following patch?

Code: Select all

Index: magick/token.c
===================================================================
--- magick/token.c	(revision 1732)
+++ magick/token.c	(working copy)
@@ -529,8 +529,8 @@
       case '\\':
       {
         pattern+=GetUTFOctets(pattern);
-        if (GetUTFCode(pattern) != 0)
-          pattern+=GetUTFOctets(pattern);
+        if (GetUTFCode(pattern) == 0)
+          break;
       }
       default:
       {

Re: Backslash escaping in GlobExpression()

Posted: 2010-04-23T09:22:44-07:00
by magick
Thanks. We'll get your patch into the next point release of ImageMagick.