mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-03 17:59:50 +02:00
fix(bin): properly escape arguments (#788)
This commit is contained in:
parent
f3f5be0b1a
commit
2f57a86a80
8 changed files with 106 additions and 79 deletions
|
@ -1,5 +1,3 @@
|
|||
import { splitCommand } from "@yume-chan/adb";
|
||||
|
||||
import type { Cmd } from "./service.js";
|
||||
|
||||
export function resolveFallback(
|
||||
|
@ -31,13 +29,7 @@ export function serializeAbbService(
|
|||
): string {
|
||||
checkCommand(command);
|
||||
|
||||
// `abb` mode doesn't use `sh -c` to execute to command,
|
||||
// so it doesn't accept escaped arguments.
|
||||
// `splitCommand` can be used to remove the escaping,
|
||||
// each item in `command` must be a single argument.
|
||||
const newCommand = command.map((arg) => splitCommand(arg)[0]!);
|
||||
|
||||
// `abb` mode uses `\0` as the separator, allowing space in arguments.
|
||||
// The last `\0` is required for older versions of `adb`.
|
||||
return `${prefix}:${newCommand.join("\0")}\0`;
|
||||
return `${prefix}:${command.join("\0")}\0`;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue