sidlatau / flutter_document_picker

Allows user pick a document. Picked document is copied to app temporary directory. Optionally allows pick document with specific extension only.
Apache License 2.0
41 stars 29 forks source link

Opening document from Google Drive may cause app to crash #17

Closed jongkb closed 5 years ago

jongkb commented 5 years ago

I discovered an edge case where opening a file from Google Drive may cause the plugin to crash. I believe this has to do with filename characters which are valid on the Drive platform but invalid on the local platform.

Repro steps: (Android)

  1. Create/upload/rename a file on Google Drive with filename containing at least an Android filename reserved character. For example: Report_2018/12/08.txt ( / being the offending character on Android but valid on Drive)

  2. Open the document using the plugin from a Flutter app. App crashes with java.lang.RuntimeException: An error occurred while executing doInBackground() ... Caused by: java.io.FileNotFoundException: /data/user/0/com.example.myapp/cache/Report_2018/12/08.txt (No such file or directory)

Expected behavior: Plugin should return a sanitized path after opening the document.

Thanks in advance and keep up the good work.

sidlatau commented 5 years ago

I added ability to sanitize file name. Plugin version 1.2.0 will automatically replace all / symbols to _. If you find any other invalid symbol, you can provide it to plugin via invalidFileNameSymbols parameter.

jongkb commented 5 years ago

Thanks for the fix! Works great now.