summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorWilliam A. Rowe Jr <wrowe@apache.org>2011-05-18 16:27:46 +0000
committerWilliam A. Rowe Jr <wrowe@apache.org>2011-05-18 16:27:46 +0000
commit723f843c220c064d0cffd7d08d155d25fbbe4819 (patch)
treeaa28b85b0b2f360aede8d2b43231266498d3e89a /strings
parenta06d241c58fc7b1bc000873f0b488c5c557a7ea1 (diff)
downloadapr-723f843c220c064d0cffd7d08d155d25fbbe4819.tar.gz
Fix PR 51219, /foo against /foo/bar.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1124326 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'strings')
-rw-r--r--strings/apr_fnmatch.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/strings/apr_fnmatch.c b/strings/apr_fnmatch.c
index 0b00846e5..b6741ef4e 100644
--- a/strings/apr_fnmatch.c
+++ b/strings/apr_fnmatch.c
@@ -207,7 +207,10 @@ APR_DECLARE(int) apr_fnmatch(const char *pattern, const char *string, int flags)
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 *pattern, const char *string, int flags)
++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 *pattern, const char *string, int flags)
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 */