mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-23 06:46:02 +00:00
fix: file provider rejects document ids with . or .. segments (#1016)
This commit is contained in:
1 parent
5f9acf51d4
commit
276bfd7fa2
1 file changed
+2
-2
@@ -85,7 +85,7 @@ class AppFilesProvider : DocumentsProvider() {
|
|||||||
|
|
||||||
override fun deleteDocument(documentId: String) {
|
override fun deleteDocument(documentId: String) {
|
||||||
val file = fileFor(documentId)
|
val file = fileFor(documentId)
|
||||||
if (file.absolutePath == base.absolutePath) throw FileNotFoundException("the app folder itself is not deleted")
|
if (file.canonicalPath == baseCanonical) throw FileNotFoundException("the app folder itself is not deleted")
|
||||||
try {
|
try {
|
||||||
deleteTree(file.toPath())
|
deleteTree(file.toPath())
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
@@ -154,7 +154,7 @@ class AppFilesProvider : DocumentsProvider() {
|
|||||||
|
|
||||||
private fun fileFor(documentId: String): File {
|
private fun fileFor(documentId: String): File {
|
||||||
val f = File(documentId)
|
val f = File(documentId)
|
||||||
if (!f.isAbsolute || !inside(f)) throw FileNotFoundException("$documentId is outside the app's files")
|
if (!f.isAbsolute || f.normalize().path != documentId || !inside(f)) throw FileNotFoundException("$documentId is outside the app's files")
|
||||||
if (!f.exists()) throw FileNotFoundException("$documentId not found")
|
if (!f.exists()) throw FileNotFoundException("$documentId not found")
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user