Skip to content

Commit 47d8312

Browse files
committed
builder-flatpak-utils: Normalize the single trailing slash in pattern
Fixes: #476
1 parent a825a09 commit 47d8312

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

src/builder-flatpak-utils.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@ flatpak_path_match_prefix (const char *pattern,
147147
while (*string == '/')
148148
string++;
149149

150+
{
151+
size_t len = strlen (pattern);
152+
if (len > 1 && pattern[len - 1] == '/')
153+
{
154+
g_autofree char *normalized = g_strndup (pattern, len - 1);
155+
return flatpak_path_match_prefix (normalized, string);
156+
}
157+
}
158+
150159
while (TRUE)
151160
{
152161
switch (c = *pattern++)

tests/test-builder-cleanup.sh

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ set -euo pipefail
2323

2424
skip_without_fuse
2525

26-
echo "1..7"
26+
echo "1..8"
2727

2828
setup_repo
2929
install_repo
@@ -256,3 +256,27 @@ assert_not_has_file appdir/files/a1/file.txt
256256
assert_has_file appdir/files/a/b/file.txt
257257

258258
echo "ok '?' does not match '/'"
259+
260+
cat > test-cleanup-trailing-slash.json <<'EOF'
261+
{
262+
"app-id": "org.test.CleanupTrailingSlash",
263+
"runtime": "org.test.Platform",
264+
"sdk": "org.test.Sdk",
265+
"cleanup": ["/share/doc/"],
266+
"modules": [{
267+
"name": "test",
268+
"buildsystem": "simple",
269+
"build-commands": [
270+
"mkdir -p /app/share/doc",
271+
"echo x > /app/share/doc/file"
272+
]
273+
}]
274+
}
275+
EOF
276+
277+
run_build test-cleanup-trailing-slash.json
278+
279+
assert_not_has_file appdir/files/share/doc/file
280+
assert_not_has_dir appdir/files/share/doc
281+
282+
echo "ok trailing slash works"

0 commit comments

Comments
 (0)