Patterns such as foo_@v/bar.efi are documented to
match files in versioned subdirectories,
but pattern_match() assumed that a field is
always followed by a literal when another element exists.
Handle a following slash as a delimiter too,
and request another recursion step
when the current path ends before that slash.
Fixes #42895.
Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
}
if (e->elements_next) {
- /* The next element must be literal, as we use it to determine where to split */
- assert(e->elements_next->type == PATTERN_LITERAL);
-
- n = strstr(p, e->elements_next->literal);
- if (!n)
- goto nope;
+ if (e->elements_next->type == PATTERN_LITERAL) {
+ n = strstr(p, e->elements_next->literal);
+ if (!n)
+ goto nope;
+ } else if (e->elements_next->type == PATTERN_SLASH)
+ n = strchrnul(p, '/');
+ else
+ assert_not_reached();
} else
/* End of the string */