disable logcat on release builds, add shellexcape prevention fun
This commit is contained in:
@@ -6,13 +6,26 @@
|
||||
package sh.sar.isodroid.root
|
||||
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import sh.sar.isodroid.BuildConfig
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
object RootManager {
|
||||
|
||||
/**
|
||||
* Escapes a string for safe use in shell commands.
|
||||
* Uses single quotes and escapes any single quotes within the string.
|
||||
* This prevents command injection via $(), ``, ;, &&, ||, etc.
|
||||
*/
|
||||
fun shellEscape(s: String): String {
|
||||
// Single quotes prevent all shell interpretation except for single quotes themselves
|
||||
// To include a single quote, we end the single-quoted string, add an escaped single quote, and start a new single-quoted string
|
||||
// Example: "test'file" becomes 'test'\''file'
|
||||
return "'" + s.replace("'", "'\\''") + "'"
|
||||
}
|
||||
|
||||
init {
|
||||
Shell.enableVerboseLogging = true
|
||||
Shell.enableVerboseLogging = BuildConfig.DEBUG
|
||||
Shell.setDefaultBuilder(
|
||||
Shell.Builder.create()
|
||||
.setFlags(Shell.FLAG_MOUNT_MASTER or Shell.FLAG_REDIRECT_STDERR)
|
||||
|
||||
Reference in New Issue
Block a user