diff options
author | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2011-04-30 23:27:16 +0000 |
---|---|---|
committer | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2011-04-30 23:27:16 +0000 |
commit | f865304903cd5695abf69362814e51968a0d7702 (patch) | |
tree | 0c7404d2d3444a5a8b8ee024f8041b843e38de8a /strings | |
parent | bb835f7ea1f69051d81286b66483f0978811e381 (diff) | |
download | libapr-f865304903cd5695abf69362814e51968a0d7702.tar.gz |
Document a mess of apr_fnmatch_test bugs mostly due
to the missing flags arg.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.4.x@1098185 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'strings')
-rw-r--r-- | strings/apr_fnmatch.c | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/strings/apr_fnmatch.c b/strings/apr_fnmatch.c index aa250ecdc..421b25533 100644 --- a/strings/apr_fnmatch.c +++ b/strings/apr_fnmatch.c @@ -211,40 +211,48 @@ static const char *rangematch(const char *pattern, int test, int flags) } -/* This function is an Apache addition */ -/* return non-zero if pattern has any glob chars in it */ +/* This function is an Apache addition + * return non-zero if pattern has any glob chars in it + * @bug Function does not distinguish for FNM_PATHNAME mode, which renders + * a false positive for test[/]this (which is not a range, but + * seperate test[ and ]this segments and no glob.) + * @bug Function does not distinguish for non-FNM_ESCAPE mode. + * @bug Function does not parse []] correctly + * Solution may be to use fnmatch_ch() to walk the patterns? + */ APR_DECLARE(int) apr_fnmatch_test(const char *pattern) { int nesting; nesting = 0; while (*pattern) { - switch (*pattern) { - case '?': - case '*': - return 1; + switch (*pattern) { + case '?': + case '*': + return 1; - case '\\': - if (*++pattern == '\0') { - return 0; - } - break; + case '\\': + if (*++pattern == '\0') { + return 0; + } + break; - case '[': /* '[' is only a glob if it has a matching ']' */ - ++nesting; - break; + case '[': /* '[' is only a glob if it has a matching ']' */ + ++nesting; + break; - case ']': - if (nesting) { - return 1; - } - break; - } - ++pattern; + case ']': + if (nesting) { + return 1; + } + break; + } + ++pattern; } return 0; } + /* Find all files matching the specified pattern */ APR_DECLARE(apr_status_t) apr_match_glob(const char *pattern, apr_array_header_t **result, |