J-D-K / JKSV

JK's Save Manager Switch Edition
GNU General Public License v3.0
1.42k stars 104 forks source link

WebDav Backup of games with invalid characters on their names. #235

Closed impeeza closed 3 months ago

impeeza commented 3 months ago

Some games which their name have invalid characters, can not create backups on WebDav Client

By example the game "Princess Peach: Showtime!" have ":" on their name, normal local JKSV backup creates the folder "Princess Peach Showtime!" replacing the invalid character by a space " ", but the WevDav process do not make this translation so the backup try to create the file:

"PUT /Entrada/JKSV/Princess%20Peach%3A%20Showtime%21/Impeeza%20-%202024.07.12%20%40%2022.49.50.zip" ("PUT/Entrada/JKSV/Princess Peach: Showtime!/Impeeza - 2024.07.12 @ 22.49.50.zip"

So Apache on Windows can not create the folder therefore no backup can be transmitted.

By the way, So many Switch games have a ":" on their names!!!

rado0x54 commented 3 months ago

First of all, this a windows specific problem and does not directly have to do with the WebDav or Google Drive implementation. In fact, I did not run across this issue because I only run my webdav services on linux-based OSes.

However, it seems that @J-D-K already came across the issue and solved it by added a parameter safeTitle that removes a number of unsafe characters from the titlename or even falls back to the Title ID.

I've updated the implementation to use safeTitle for the remote fs as well. (#236). However this is a breaking change. If saves existed with title on the remote fs, they need to be moved manually. I've added a warning to the REMOTE_INSTRUCTIONS.MD around that.

J-D-K commented 3 months ago

@rado0x54 That was actually implemented because Nintendo's FS doesn't work properly with UTF8 paths on the SD card for some reason. Google drive never seemed to have issues with special characters in titles so I didn't bother using path safe titles. But, if it gets the job done, whatever.

impeeza commented 3 months ago

Yeah Google Drive can care less about the characters on the path, but DOS is another history, you can not even use «CON» or «LPT» as a name!! and yes I tell DOS because even Windows 22H2 is running Kernel safeties for DOS backward compatibility. And for DOS ":" is a NO NO NO, NEVER IN THE F LIFE because the disk are accessed normally by a letter and colon.

Thanks guys for the great work.

impeeza commented 3 months ago

Build, and working as should, now my «Princess Peach: Sowtime!» save game backup is on:

"Z:\Nintendo Switch\Respaldos_Saves_WebDav\JKSV\Princess Peach Showtime!"

Via Apache on Windows 11!

By the way I just found an old text file on my PC

The forbidden printable ASCII characters are:

    Linux/Unix:

    / (forward slash)

    Windows:

    < (less than)
    > (greater than)
    : (colon - sometimes works, but is actually NTFS Alternate Data Streams)
    " (double quote)
    / (forward slash)
    \ (backslash)
    | (vertical bar or pipe)
    ? (question mark)
    * (asterisk)

Non-printable characters

If your data comes from a source that would permit non-printable characters then there is more to check for.

    Linux/Unix:

    0 (NULL byte)

    Windows:

    0-31 (ASCII control characters)

Note: While it is legal under Linux/Unix file systems to create files with control characters in the filename, [it might be a nightmare for the users to deal with such files](https://dwheeler.com/essays/fixing-unix-linux-filenames.html).

Reserved file names

The following filenames are reserved:

    Windows:

    CON, PRN, AUX, NUL 
    COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9
    LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9

    (both on their own and with arbitrary file extensions, e.g. LPT1.txt).

Other rules

    Windows:

    Filenames cannot end in a space or dot.

    macOS:

    Colon : and forward slash / depending on context are not permitted (e.g. Finder supports slashes, terminal supports colons). [(More details)](https://superuser.com/questions/326103/what-are-invalid-characters-for-a-file-name-under-os-x)

:P

Again, thanks a lot for all your effort.

impeeza commented 3 months ago

@J-D-K hope you don't mind, I published a build of latest code with the PR included on GBATemp.