Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

File uploads with file name containing a path #228

Closed
christarazi opened this issue Dec 31, 2017 · 4 comments · Fixed by element-hq/riot-android#2019
Closed

File uploads with file name containing a path #228

christarazi opened this issue Dec 31, 2017 · 4 comments · Fixed by element-hq/riot-android#2019
Labels

Comments

@christarazi
Copy link

christarazi commented Dec 31, 2017

Different clients may choose to put the entire file path in m.body when uploading files, which is used as the default file name in saveMedia. A toast appears with an error: No such file or directory when trying to save the file.

Perhaps detecting if a file name contains a path, and just trimming it to contain only the name would fix the issue. I thought I'd inform you guys here to get your opinion instead of creating a PR immediately.

@christarazi christarazi changed the title File uploads with file name as full path File uploads with file name contaning a path Dec 31, 2017
@christarazi christarazi changed the title File uploads with file name contaning a path File uploads with file name containing a path Dec 31, 2017
@ylecollen
Copy link
Contributor

@christarazi
The m.body sets to the filename is the same behaviour on all the plaforms.
This body is the value displayed in the recents list for example.

It would be weird to have "C:\users..." on an android device.

Moreover, the windows pathes won't be detected as valid ones on other platforms.
On IOS, you don't have the full path.

Even on android platforms, the path might be different.

@christarazi
Copy link
Author

christarazi commented Jan 15, 2018

I think we might have a misunderstanding.

I am suggesting to have Riot look at m.body, and if it contains a file path (relative or absolute), then when saving files, trim m.body to only the filename.

For example:

/path/to/file -> file
c:\path\to\file -> file

The reason is because some clients choose to put the entire file path in m.body, which is not explicitly disallowed in the spec. When using Riot to download them, it will try to save the file to the path specified in m.body, which causes Riot to fail and display an error (unless that path exists on the device).

@ghost
Copy link

ghost commented Jan 20, 2018

Riot should at the very least sanitize the filename it is trying to save to.

christarazi added a commit to christarazi/riot-android that referenced this issue Feb 25, 2018
christarazi added a commit to christarazi/riot-android that referenced this issue Mar 1, 2018
This fixes matrix-org/matrix-android-sdk#228.

Signed-off-by: Chris Tarazi <tarazichris@gmail.com>
@christarazi
Copy link
Author

Closing as element-hq/riot-android#2019 has been merged.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants