mirror of
https://github.com/moparisthebest/curl
synced 2024-11-17 15:05:02 -05:00
fnmatch: do not match the empty string with a character set
This commit is contained in:
parent
2b50e56343
commit
19abad095c
@ -352,6 +352,8 @@ static int loop(const unsigned char *pattern, const unsigned char *string,
|
|||||||
unsigned char *pp = p + 1; /* cannot handle with pointer to register */
|
unsigned char *pp = p + 1; /* cannot handle with pointer to register */
|
||||||
if(setcharset(&pp, charset)) {
|
if(setcharset(&pp, charset)) {
|
||||||
int found = FALSE;
|
int found = FALSE;
|
||||||
|
if(!*s)
|
||||||
|
return CURL_FNMATCH_NOMATCH;
|
||||||
if(charset[(unsigned int)*s])
|
if(charset[(unsigned int)*s])
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
else if(charset[CURLFNM_ALNUM])
|
else if(charset[CURLFNM_ALNUM])
|
||||||
@ -380,8 +382,6 @@ static int loop(const unsigned char *pattern, const unsigned char *string,
|
|||||||
|
|
||||||
if(found) {
|
if(found) {
|
||||||
p = pp + 1;
|
p = pp + 1;
|
||||||
if(*s)
|
|
||||||
/* don't advance if we're matching on an empty string */
|
|
||||||
s++;
|
s++;
|
||||||
memset(charset, 0, CURLFNM_CHSET_SIZE);
|
memset(charset, 0, CURLFNM_CHSET_SIZE);
|
||||||
}
|
}
|
||||||
|
@ -97,8 +97,8 @@ static const struct testcase tests[] = {
|
|||||||
{ "*[^a].t?t", "a.txt", NOMATCH },
|
{ "*[^a].t?t", "a.txt", NOMATCH },
|
||||||
{ "*[^a].t?t", "ba.txt", NOMATCH },
|
{ "*[^a].t?t", "ba.txt", NOMATCH },
|
||||||
{ "*[^a].t?t", "ab.txt", MATCH },
|
{ "*[^a].t?t", "ab.txt", MATCH },
|
||||||
{ "*[^a]", "", MATCH },
|
{ "*[^a]", "", NOMATCH },
|
||||||
{ "[!ÿ]", "", MATCH },
|
{ "[!ÿ]", "", NOMATCH },
|
||||||
{ "[!?*[]", "?", NOMATCH },
|
{ "[!?*[]", "?", NOMATCH },
|
||||||
{ "[!!]", "!", NOMATCH },
|
{ "[!!]", "!", NOMATCH },
|
||||||
{ "[!!]", "x", MATCH },
|
{ "[!!]", "x", MATCH },
|
||||||
|
Loading…
Reference in New Issue
Block a user