#9976·rclone

vfs/encoder: a non-identity remote encoding can merge two distinct names, and U+201B names grow on every decode

Author: KurptasCreated Sep 25, 2026Updated Sep 25, 2026

Two naming defects in the encoding layer (independent of the write-back data loss)

Both measured with the encoder library itself and with a mount; neither is addressed by #9974/#9975 (which are about the write-back path) and neither is the same as the rename data loss in #9943.

1. A non-identity encoding on a remote can merge two distinct remote names

Colon in a remote's mask means "a : is stored on this remote as :". Decoding therefore maps a bare fullwidth : back to :, so on a remote that (legally, e.g. Linux) holds both A:B.txt and A:B.txt, the two different files collapse into the same internal name. Computed with lib/encoder (scratch module with a replace onto a checkout):

remote mask ToStandardName("A:B.txt") ToStandardName("A:B.txt") collision
default (Display/Standard) A:B.txt A:B.txt no
None A:B.txt A:B.txt no
Slash,Dot A:B.txt A:B.txt no
Windows set (Slash,Dot,Colon,Question,…) A:B.txt A:B.txt yes
Raw A:B.txt A:B.txt no

Consequences measured on a mount with that mask: saving a file whose remote name is the bare fullwidth spelling writes back the quoted form (A‛:B.txt, U+201B) leaving the original untouched; the mount displays a remote halfwidth name through WinFsp's private-use escape (A+U+F03A+B.txt); and a halfwidth name is rewritten as the fullwidth spelling on save, i.e. it can clobber the sibling that legitimately owns that spelling. Today's workaround is configuration only: leave encoding unset on network remotes (SFTP/FTP default is encoder.Display, which is identity), or use Raw.

2. Decoding is not idempotent: names containing U+201B grow on every pass

ToStandardName is Standard.Encode(e.Decode(s)) and Standard.Encode escapes every existing QuoteRune (lib/encoder/encoder.go:452-455, the only early-out is EncodeRaw at :221-223), so a name that already contains ‛ gains one more ‛ each time it is decoded. Measured: A‛:B.txt -> A‛‛:B.txt per pass for None/Slash,Dot/Raw; 1 -> 2 -> 4 -> 8 for Raw; Standard/Display is a special case and is identity (:1235). Anything that decodes repeatedly (every directory listing; the VFS dir cache) therefore inflates such names and can show mount entries the remote does not have.

The docs (docs/content/overview.md:183) say the ‛ escaping is intentional (to disambiguate a literal fullwidth character from an escaped halfwidth one), so this is not "remove the quoting": the canonical spelling has to be settled so that both From∘To == id and To∘To == To hold. Today only the first holds, which is why a single extra decode mangles a name.

3. Direction asymmetry (probably the same root)

With everything left at defaults: rclone copy of a local Windows file named 报告:2026.txt stores 报告:2026.txt on the remote (the local backend decodes the fullwidth colon), while rclone copy of a remote 报告:2026.txt down to Windows produces the local name 报告‛:2026.txt; copying through a mount preserves the spelling in both directions. Adding --local-encoding Slash,Dot makes both copy directions preserve the name (measured on both an SFTP remote and a Windows-hosted SFTP server, where the default behaviour additionally fails: NTFS cannot hold a halfwidth colon, so the file lands as 报告 plus an NTFS alternate data stream or the transfer errors).

Reproducers

# name-preserving stand-in for a NAS
rclone serve sftp --local-encoding Raw --no-auth --addr 127.0.0.1:2253 /tmp/nas
# remote file with a literal fullwidth colon, mount, save it through the mount
rclone mount :sftp,host=127.0.0.1,port=2253,user=u,vendor=other: X: --vfs-cache-mode full --dir-cache-time 3s -vv
# and, for the copy direction:
rclone copy <dir with 报告:2026.txt> <remote>:dest            # lands as 报告:2026.txt
rclone copy <dir with 报告:2026.txt> <remote>:dest --local-encoding Slash,Dot   # keeps 报告:2026.txt

Related: #7760 (the earlier partial fix, which made the cache's temp-file encoding uniform) and #9943 (the write-back data loss, a different defect). I am not proposing a change here — a fix has to decide the canonical spelling and preserve existing names, so it needs maintainer input.