-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6542 from seadowg/v2024.3.3-changes
Changes for v2024.3.3
- Loading branch information
Showing
10 changed files
with
47 additions
and
36 deletions.
There are no files selected for viewing
27 changes: 0 additions & 27 deletions
27
androidshared/src/main/java/org/odk/collect/androidshared/utils/PathUtils.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
collect_app/src/main/java/org/odk/collect/android/fastexternalitemset/ItemsetDbAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package org.odk.collect.shared | ||
|
||
import org.odk.collect.shared.files.FileExt.sanitizedCanonicalPath | ||
import java.io.File | ||
|
||
object PathUtils { | ||
|
||
@JvmStatic | ||
|
@@ -10,4 +13,16 @@ object PathUtils { | |
// https://stackoverflow.com/questions/2679699/what-characters-allowed-in-file-names-on-android | ||
@JvmStatic | ||
fun getPathSafeFileName(fileName: String) = fileName.replace("[\"*/:<>?\\\\|]".toRegex(), "_") | ||
|
||
@JvmStatic | ||
fun getAbsoluteFilePath(dirPath: String, filePath: String): String { | ||
val absoluteFilePath = | ||
if (filePath.startsWith(dirPath)) filePath else dirPath + File.separator + filePath | ||
|
||
if (File(absoluteFilePath).sanitizedCanonicalPath().startsWith(File(dirPath).sanitizedCanonicalPath())) { | ||
return absoluteFilePath | ||
} else { | ||
throw SecurityException("Contact [email protected]. Attempt to access file outside of Collect directory: $absoluteFilePath") | ||
} | ||
} | ||
} |