Backslash escaping in GlobExpression()

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
tstarling
Posts: 3
Joined: 2010-04-22T05:03:56-07:00
Authentication code: 8675308

Backslash escaping in GlobExpression()

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Backslash escaping in GlobExpression()

Post 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,
tstarling
Posts: 3
Joined: 2010-04-22T05:03:56-07:00
Authentication code: 8675308

Re: Backslash escaping in GlobExpression()

Post 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:
       {
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Backslash escaping in GlobExpression()

Post by magick »

Thanks. We'll get your patch into the next point release of ImageMagick.
Post Reply