Fixed: Fix TermuxService failing to execute files with "#"

am startservice --user 0 -n com.termux/.app.TermuxService -a com.termux.service_execute -d "file:///data/data/com.termux/files/home/te#st.sh"
This commit is contained in:
agnostic-apollo 2021-10-23 04:20:16 +05:00
parent 3e518a6a75
commit b559d5a0bd
1 changed files with 5 additions and 1 deletions

View File

@ -26,6 +26,7 @@ import com.termux.app.settings.properties.TermuxAppSharedProperties;
import com.termux.app.terminal.TermuxTerminalSessionClient;
import com.termux.app.utils.PluginUtils;
import com.termux.shared.data.IntentUtils;
import com.termux.shared.data.UriUtils;
import com.termux.shared.models.errors.Errno;
import com.termux.shared.shell.ShellUtils;
import com.termux.shared.termux.shell.TermuxShellEnvironmentClient;
@ -360,7 +361,10 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
executionCommand.inBackground = intent.getBooleanExtra(TERMUX_SERVICE.EXTRA_BACKGROUND, false);
if (executionCommand.executableUri != null) {
executionCommand.executable = executionCommand.executableUri.getPath();
Logger.logVerbose(LOG_TAG, "uri: \"" + executionCommand.executableUri + "\", path: \"" + executionCommand.executableUri.getPath() + "\", fragment: \"" + executionCommand.executableUri.getFragment() + "\"");
// Get full path including fragment (anything after last "#")
executionCommand.executable = UriUtils.getUriFilePath(executionCommand.executableUri);
executionCommand.arguments = IntentUtils.getStringArrayExtraIfSet(intent, TERMUX_SERVICE.EXTRA_ARGUMENTS, null);
if (executionCommand.inBackground)
executionCommand.stdin = IntentUtils.getStringExtraIfSet(intent, TERMUX_SERVICE.EXTRA_STDIN, null);