sysupdate: handle slashes after pattern fields

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>
This commit is contained in:
dongshengyuan
2026-07-06 13:40:26 +08:00
committed by Kai Lüke
parent c944af8459
commit add910a838

View File

@@ -248,12 +248,14 @@ int pattern_match(const char *pattern, const char *s, InstanceMetadata *ret) {
}
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 */