apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r1124326 - /apr/apr/trunk/strings/apr_fnmatch.c
Date Wed, 18 May 2011 16:27:46 GMT
Author: wrowe
Date: Wed May 18 16:27:46 2011
New Revision: 1124326

URL: http://svn.apache.org/viewvc?rev=1124326&view=rev
Log:
Fix PR 51219, /foo against /foo/bar.

Modified:
    apr/apr/trunk/strings/apr_fnmatch.c

Modified: apr/apr/trunk/strings/apr_fnmatch.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/strings/apr_fnmatch.c?rev=1124326&r1=1124325&r2=1124326&view=diff
==============================================================================
--- apr/apr/trunk/strings/apr_fnmatch.c (original)
+++ apr/apr/trunk/strings/apr_fnmatch.c Wed May 18 16:27:46 2011
@@ -207,7 +207,10 @@ APR_DECLARE(int) apr_fnmatch(const char 
     const char *mismatch = NULL;
     int matchlen = 0;
 
-    while (*pattern)
+    if (*pattern == '*')
+        goto firstsegment;
+
+    while (*pattern && *string)
     {
         /* Pre-decode "\/" which has no special significance, and
          * match balanced slashes, starting a new segment pattern
@@ -219,6 +222,7 @@ APR_DECLARE(int) apr_fnmatch(const char 
             ++string;
         }            
 
+firstsegment:
         /* At the beginning of each segment, validate leading period behavior.
          */
         if ((flags & APR_FNM_PERIOD) && (*string == '.'))
@@ -379,9 +383,9 @@ APR_DECLARE(int) apr_fnmatch(const char 
             return APR_FNM_NOMATCH;
     }
 
-    /* pattern is at EOS; if string is also, declare success
+    /* Where both pattern and string are at EOS, declare success
      */
-    if (!*string)
+    if (!*string && !*pattern)
         return 0;
 
     /* pattern didn't match to the end of string */



Mime
View raw message