fnmatch: accept an alphanum to be followed by a non-alphanum in char set

Also be more tolerant about set pattern syntax.
Update unit test 1307 accordingly.

Bug: https://curl.haxx.se/mail/lib-2018-01/0114.html
This commit is contained in:
Patrick Monnerat 2018-01-29 16:21:50 +01:00
parent 19abad095c
commit fcaa1826bd
2 changed files with 62 additions and 94 deletions

View file

@ -36,8 +36,8 @@ struct testcase {
static const struct testcase tests[] = {
/* brackets syntax */
{ "\\[", "[", MATCH },
{ "[", "[", RE_ERR },
{ "[]", "[]", RE_ERR },
{ "[", "[", MATCH },
{ "[]", "[]", MATCH },
{ "[][]", "[", MATCH },
{ "[][]", "]", MATCH },
{ "[[]", "[", MATCH },
@ -49,6 +49,8 @@ static const struct testcase tests[] = {
{ "[][[[]", "[", MATCH },
{ "[[]", "]", NOMATCH },
{ "[a@]", "a", MATCH },
{ "[a-z]", "a", MATCH },
{ "[a-z]", "A", NOMATCH },
{ "?[a-z]", "?Z", NOMATCH },
@ -77,6 +79,7 @@ static const struct testcase tests[] = {
{ "[][?*-]", "*", MATCH },
{ "[][?*-]", "-", MATCH },
{ "[]?*-]", "-", MATCH },
{ "[\xFF]", "\xFF", MATCH },
{ "?/b/c", "a/b/c", MATCH },
{ "^_{}~", "^_{}~", MATCH },
{ "!#%+,-./01234567889", "!#%+,-./01234567889", MATCH },
@ -98,7 +101,9 @@ static const struct testcase tests[] = {
{ "*[^a].t?t", "ba.txt", NOMATCH },
{ "*[^a].t?t", "ab.txt", MATCH },
{ "*[^a]", "", NOMATCH },
{ "[!ÿ]", "", NOMATCH },
{ "[!\xFF]", "", NOMATCH },
{ "[!\xFF]", "\xFF", NOMATCH },
{ "[!\xFF]", "a", MATCH },
{ "[!?*[]", "?", NOMATCH },
{ "[!!]", "!", NOMATCH },
{ "[!!]", "x", MATCH },