zhanghai / MaterialFiles

Material Design file manager for Android
https://play.google.com/store/apps/details?id=me.zhanghai.android.files
GNU General Public License v3.0
6.12k stars 413 forks source link

FTP uploading folders with special characters (such as `>`, `:`, etc.) in their names causes "ECONNRESET - Connection reset by peer" and "Page type unknown" #1334

Open nekohayo opened 3 weeks ago

nekohayo commented 3 weeks ago

Hi !

With the latest version available in f-droid (1.7.4) on Android 14, I've been trying to upload a bunch of music album folders but they end up causing a bunch of incomprehensible errors in Nautilus and FileZilla when they try to copy the actual files in those folders, when the folder names have characters such as : or > in them.

The weird thing is that in the Material Files interface, and through FTP, it is quite possible to create, rename, view such folders even with special characters. It only fails to upload files to them.

For example, if I create a folder called blah : in the Music folder, and try to upload to it, for each file FileZilla reports:

Could not read from transfer socket: ECONNRESET - Connection reset by peer

Nautilus / GVFS reports:

There was an error copying the file into ftp://admin@the_phone:2121/Music/blah%20:.

Error sending data: Connection reset by peer

If you try to create a file in such a folder (instead of just copying), Nautilus' error is slightly different:

There was an error creating the directory in ftp://admin@the_phone:2121/Music/blah%20:.

Page type unknown

Given that two different types of FTP clients are choking on this in different ways, I am wondering if there is something Material Files can do to translate the paths+filenames when receiving (or creating, modifying etc.) files through FTP specifically? Otherwise, is there a way for Material Files to raise a more descriptive error for the FTP clients? Or prevent the creation of those faulty folders (instead of later failing on the files within)?

nekohayo commented 3 weeks ago

Apparently, uploading folders with such characters in their filenames also fails with similar errors even if the containing folder has no special characters, but I'm not sure what to do about files. It would still be desirable to have something more descriptive than "Connection reset by peer", if possible...

zhanghai commented 3 weeks ago

If you are trying to put files on your SD card and your file/folder name contains special characters like :, that will fail due to stricter FAT32 file name enforcement on new Android versions. See also https://github.com/google/adb-sync/issues/34 .

Maybe Material Files can provide a better error message, but Material Files shouldn't translate the file name for you because there's no canonical way to do that. You need to transform the file name properly with your own copy mechanism.