From c2d653006577a09e55d5f6b841e74a95901c34b3 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Fri, 19 Dec 2025 16:26:31 +0200 Subject: [PATCH] added test for file name normalization with leading dot --- CHANGELOG.md | 5 +++-- tools/filesystem/file.go | 3 +++ tools/filesystem/file_test.go | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9659aeee..618d47a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,12 @@ -## v0.35 (WIP) +## v0.35.0 - Added `nullString()`, `nullInt()`, `nullFloat()`, `nullBool`, `nullArray()`, `nullObject()` JSVM helpers for scanning nullable columns ([#7396](https://github.com/pocketbase/pocketbase/issues/7396)). (@todo update the landing docs) - Store the correct `image/png` as attrs content type when generating a thumb fallback _(e.g. for `webp`)_. -- Trimmed the normalized file extension from leftover `.` characters after cleanup. +- Trimmed the uploaded file name and extension from leftover `.` characters after normalization. + _This was done to prevent issues with external files sync programs that may have special handling for "invisible" files._ - Updated Go deps. diff --git a/tools/filesystem/file.go b/tools/filesystem/file.go index 7b1a863c..6be55bac 100644 --- a/tools/filesystem/file.go +++ b/tools/filesystem/file.go @@ -207,6 +207,9 @@ func normalizeName(fr FileReader, name string) string { } // name + // + // note: leading dot is trimmed to prevent various subtle issues with files + // sync programs as they sometimes have special handling for "invisible" files // --- cleanName := inflector.Snakecase(strings.Trim(strings.TrimSuffix(name, originalExt), ".")) if length := len(cleanName); length < 3 { diff --git a/tools/filesystem/file_test.go b/tools/filesystem/file_test.go index 10d73680..a1cf7f55 100644 --- a/tools/filesystem/file_test.go +++ b/tools/filesystem/file_test.go @@ -215,6 +215,7 @@ func TestFileNameNormalizations(t *testing.T) { {"a.b.c.?.?.?.2", `^a_b_c_\w{10}\.2$`}, {"a.b.c.d.tar.gz", `^a_b_c_d_\w{10}\.tar\.gz$`}, {"abcd", `^abcd_\w{10}\.txt$`}, + {".abcd.123.", `^abcd_\w{10}\.123$`}, {"a b! c d . 456", `^a_b_c_d_\w{10}\.456$`}, // normalize spaces {strings.Repeat("a", 101) + "." + strings.Repeat("b", 21), `^a{100}_\w{10}\.b{20}$`}, // name and extension length trim } @@ -225,7 +226,8 @@ func TestFileNameNormalizations(t *testing.T) { if err != nil { t.Fatal(err) } - if match, err := regexp.Match(s.pattern, []byte(f.Name)); !match { + match, err := regexp.Match(s.pattern, []byte(f.Name)) + if !match { t.Fatalf("Expected Name to match %v, got %q (%v)", s.pattern, f.Name, err) } })