Flutter_file_picker: Having quotes "" in file name leads to invalid file path

Created on 11 Nov 2019  路  7Comments  路  Source: miguelpruivo/flutter_file_picker

Hi, I'm trying to select the file with name ("###PDF n asdfm eesf")$".pdf but var path = await FilePicker.getFilePath(type: FileType.ANY); returns only ( as the filename. E.g. everything after the first quotation mark gets truncated. This is not good obviously. Looks like file paths aren't sanitized correctly?

bug wip

All 7 comments

Hi @travisjayday this shouldn't happen. In which platform is this issue on?

Tested on Pixel 2 API 28 virtual device. Here is the relevant code:

void _pickFile() async {
    var path = await FilePicker.getFilePath(type: FileType.ANY);
    print("Selected file: " + path.toString());
}

Thanks for the quick response btw :-)

Ok. I'll take a look ASAP @travisjayday. Thank you.

Hi @travisjayday, this looks similar to #166 where you both are using reserved Android character names. This make it even harder to debug because I can't have files with that name as it most of the times, the system will automatically replace with _. You can try it yourself by going to a File Explorer and try to rename a file to include " or any other invalid character, and you'll see that it will be replaced with an _.

Anyhow, if you find a way to force it to have that name or provide me with a url for such, I may give it a try and see what I can do. But bottom line is that there shouldn't be files with invalid file names.

Hi @miguelpruivo, reserved Android characters or not, I think it is certainly possible that users may have files with hose characters. The Pixel emulator when downloading PDF files from chrome even shows an alert Dialog in which the user can specify a file name (with however many special characters) for the downloaded PDF. I also tested this on my phone (Xiaomi mi mix 3) and the Google Files file manager app allows for renaming files with special characters + another file manager I use also allows for renaming with those special characters in the OP.

@travisjayday I understand, but you will have to provide me with full steps to reproduce your issue otherwise I can't find a way to help you as I don't really can (and believe me, I've tried even of different SDK emulators, with API 28 and 29) but the files always get renamed to _ when I try to add an invalid character like " in the name, even when downloading from Chrome.

Tell me the emulator model and API version and how are you doing it. I've even downloaded some file explorer apps in order to make it possible to rename, but some of them don't even allow me _at all_ to introduce invalid characters to the name. It's like a no-no for me.

Nevertheless, I still would like to help you.

I'm closing this since no further info was been given in the meantime. Feel free to re-open it if you have more details.

Thank you.

Was this page helpful?
0 / 5 - 0 ratings