Browse Source

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>
Marcel Hibbe 2 years ago
parent
commit
d49441e036
1 changed files with 6 additions and 4 deletions
  1. 6 4
      app/src/main/java/com/nextcloud/talk/utils/FileUtils.kt

+ 6 - 4
app/src/main/java/com/nextcloud/talk/utils/FileUtils.kt

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