mirror of
https://github.com/paul-nameless/tg
synced 2024-11-24 21:03:06 +00:00
Escape safely shell arguments for notify cmd
This commit is contained in:
parent
3843791b95
commit
6c126ab96a
1 changed files with 6 additions and 3 deletions
|
@ -170,6 +170,9 @@ def get_waveform(file_path: str) -> str:
|
||||||
return base64.b64encode(packed).decode()
|
return base64.b64encode(packed).decode()
|
||||||
|
|
||||||
|
|
||||||
|
safe_map = str.maketrans({"'": "", "`": "", "\"": ""})
|
||||||
|
|
||||||
|
|
||||||
def notify(
|
def notify(
|
||||||
msg: str,
|
msg: str,
|
||||||
subtitle: str = "",
|
subtitle: str = "",
|
||||||
|
@ -181,10 +184,10 @@ def notify(
|
||||||
notify_cmd = cmd.format(
|
notify_cmd = cmd.format(
|
||||||
icon_path=shlex.quote(config.ICON_PATH),
|
icon_path=shlex.quote(config.ICON_PATH),
|
||||||
title=shlex.quote(title),
|
title=shlex.quote(title),
|
||||||
subtitle=shlex.quote(subtitle),
|
subtitle=shlex.quote(subtitle.translate(safe_map)),
|
||||||
msg=shlex.quote(msg),
|
msg=shlex.quote(msg.translate(safe_map)),
|
||||||
)
|
)
|
||||||
subprocess.Popen(notify_cmd, shell=False)
|
subprocess.Popen(notify_cmd, shell=True)
|
||||||
|
|
||||||
|
|
||||||
def string_len_dwc(string: str) -> int:
|
def string_len_dwc(string: str) -> int:
|
||||||
|
|
Loading…
Reference in a new issue