Skip to content

[fix] Improve handling of illegal vFAT filenames.#14043

Merged
Frenzie merged 2 commits into
koreader:masterfrom
michal-mnich:fix-illegal-vfat-filenames
Jul 13, 2025
Merged

[fix] Improve handling of illegal vFAT filenames.#14043
Frenzie merged 2 commits into
koreader:masterfrom
michal-mnich:fix-illegal-vfat-filenames

Conversation

@michal-mnich

@michal-mnich michal-mnich commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

This change fixes an issue where a file/directory is not created when its name contains trailing spaces or dots. The issue has been observed on a Kobo device, but probably also applies to other systems using vFAT.

We also might want to consider handling other illegal vFAT filenames like NUL or AUX.

Please see the official Microsoft documentation for more details on the naming conventions of vFAT (this change addresses the last bullet point).


This change is Reviewable

This change fixes an issue where a file/directory is not created when its name contains trailing spaces or dots.
The issue has been observed on a Kobo device, but probably also applies to other systems using vFAT.

We also might want to consider handling other illegal vFAT filenames like `NUL` or `AUX`.

Please see the [official Microsoft documentation](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions)
for more details on the naming conventions of vFAT (this change addresses the last bullet point).
Comment thread frontend/util.lua
@Frenzie

Frenzie commented Jul 11, 2025

Copy link
Copy Markdown
Member

This change fixes an issue where a file/directory is not created when its name contains trailing spaces or dots.

It would seem that trailing dots are created, but the dots generally aren't shown and the name counts as a duplicate to without trailing dots or a different number of trailing dots. That's not an objection to stripping them or anything, mind.

@Frenzie Frenzie added this to the 2025.06 milestone Jul 11, 2025
@michal-mnich

Copy link
Copy Markdown
Contributor Author

I see your point. Actually, the current implementation would also treat file? and file: as duplicates (since both of them will become file_), similarly for other pairs of illegal characters. I think that a complete resolution of this is impossible, since the user could theoretically name the file to any of our mitigation attempts :). But maybe it would help to replace the illegal characters with their encoding of some kind (URL-like, UTF8, maybe even ASCII)? It would make an accidental collision a bit less likely.

@Frenzie

Frenzie commented Jul 11, 2025

Copy link
Copy Markdown
Member

No, I don't consider that a concern. I was describing the behavior of the /mnt/onboard filesystem on Kobo for the sake of accuracy. Only trailing spaces are problematic, give or take the edge case of trailing spaces followed by trailing dots. Creating a folder with the name test. works with any number of . (as long as you stay under 255 characters total I assume). But test or test . will not.

Comment thread frontend/util.lua Outdated
@Frenzie Frenzie merged commit 8db0dee into koreader:master Jul 13, 2025
1 of 2 checks passed
@Frenzie Frenzie added the bug label Jul 13, 2025
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
This change fixes an issue where a file/directory is not created when its name contains trailing spaces or dots.
The issue has been observed on a Kobo device, but probably also applies to other systems using vFAT.

We also might want to consider handling other illegal vFAT filenames like `NUL` or `AUX`.

Please see the [official Microsoft documentation](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions)
for more details on the naming conventions of vFAT (this change addresses the last bullet point).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants