protondrive: refuse to write names which aren't valid UTF-8

With an encoding which lets invalid UTF-8 through, rclone could create
a file or folder whose name Proton's clients, and rclone itself, then
refuse to read, so it vanished from listings. Such names are now
refused when writing.

Found by FuzzValidateName.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Opus 5.5 committed 2026-11-11 20:28:21 +01:00
1 parent 18b4f7d1d1
commit 16480e3d80
3 files changed
+6

No files matched your search

+2
View File
@@ -505,6 +505,8 @@ func validateName(name string) error {
return fmt.Errorf("name must not be %q", name)
case strings.ContainsAny(name, "/\x00"):
return errors.New("name must not contain / or NUL")
case !utf8.ValidString(name):
return errors.New("name must be valid UTF-8")
}
n := 0
for _, r := range name {
@@ -380,6 +380,9 @@ func TestValidateName(t *testing.T) {
// these takes two.
{strings.Repeat("😀", 127) + "a", true},
{strings.Repeat("😀", 128), false},
// Other clients couldn't read it back: decryptName refuses it.
{"a\xffb", false},
{"\xed\xa0\x80", false}, // a UTF-16 surrogate
} {
err := validateName(test.name)
if test.ok {
@@ -103,6 +103,7 @@ func FuzzValidateName(f *testing.F) {
return
}
assert.NotEmpty(t, name)
assert.True(t, utf8.ValidString(name), "%q", name)
assert.NotEqual(t, ".", name)
assert.NotEqual(t, "..", name)
assert.NotContains(t, name, "/")