Improve handling of files with spaces.

This commit is contained in:
Kevin Gorham 2020-07-29 02:15:00 -04:00
parent 7d95585c4e
commit 9873e9efbe
No known key found for this signature in database
GPG Key ID: CCA55602DF49FC38
1 changed files with 5 additions and 4 deletions

View File

@ -110,13 +110,14 @@ class ProfileFragment : BaseFragment<FragmentProfileBinding>() {
private fun writeLogcat(): File? {
try {
val outputFile = File("${ZcashWalletApp.instance.filesDir}/logs", "developer_log.txt")
if (!outputFile.parentFile.isFile) {
// Note: the /logs directory has been configured as a file provider under @xml/file_paths which allows the temporary sharing of this file
val outputFile = File("${ZcashWalletApp.instance.filesDir}/logs", "developer_log.txt").also { it.parentFile.mkdirs() }
if (!outputFile.parentFile.isDirectory) {
// addresses security finding in issue #121
throw IllegalArgumentException("Invalid path: ${outputFile.absolutePath}. Verify" +
throw IllegalArgumentException("Invalid path: ${outputFile.parentFile}. Verify" +
" that the default files directory is not being manipulated.")
}
val cmd = arrayOf("/bin/sh", "-c", "logcat -v time -d | grep \"@TWIG\" > \"${outputFile.absolutePath}\"")
val cmd = arrayOf("/bin/sh", "-c", "logcat -v time -d | grep '@TWIG' > '${outputFile.absolutePath}'")
Runtime.getRuntime().exec(cmd)
return outputFile
} catch (e: IOException) {