get last part after "/" also for content uris

note that this doesn't prevent path traversal as uris can be decoded

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2023-05-31 17:11:10 +02:00
parent 74e2108ef3
commit d49441e036
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B

View File

@ -149,11 +149,13 @@ object FileUtils {
// if it was no content uri, read filename from path // if it was no content uri, read filename from path
if (filename == null) { if (filename == null) {
filename = uri.path filename = uri.path
}
val lastIndexOfSlash = filename!!.lastIndexOf('/') val lastIndexOfSlash = filename!!.lastIndexOf('/')
if (lastIndexOfSlash != -1) { if (lastIndexOfSlash != -1) {
filename = filename.substring(lastIndexOfSlash + 1) filename = filename.substring(lastIndexOfSlash + 1)
} }
}
return filename return filename
} }