fix(core): decode subprocess output as UTF-8 with replacement

Strict UTF-8 decode of external tool output (ffmpeg/shaka/mp4decrypt) crashed reader threads on non-English Windows (cp950/Big5).
This commit is contained in:
imSp4rky
2026-07-07 09:23:05 -06:00
parent 5cd50544a8
commit 1dba4a8f82
15 changed files with 72 additions and 13 deletions
+18
View File
@@ -544,6 +544,8 @@ class Gluetun(Proxy):
["docker", "ps", "--format", "{{.Ports}}"],
capture_output=True,
text=True,
encoding="utf-8",
errors="replace",
timeout=5,
)
if result.returncode == 0:
@@ -892,6 +894,8 @@ class Gluetun(Proxy):
],
capture_output=True,
text=True,
encoding="utf-8",
errors="replace",
timeout=5,
)
if result.returncode != 0:
@@ -926,6 +930,8 @@ class Gluetun(Proxy):
["docker", "inspect", container_name, "--format", "{{.NetworkSettings.Ports}}"],
capture_output=True,
text=True,
encoding="utf-8",
errors="replace",
timeout=5,
)
@@ -1109,6 +1115,8 @@ class Gluetun(Proxy):
["docker", "inspect", container_name, "--format", "{{.State.ExitCode}}:{{.State.Error}}"],
capture_output=True,
text=True,
encoding="utf-8",
errors="replace",
timeout=5,
)
if result.returncode == 0:
@@ -1310,6 +1318,8 @@ class Gluetun(Proxy):
["docker", "ps", "-a", "--filter", f"name=^{container_name}$", "--format", "{{.Names}}:{{.Status}}"],
capture_output=True,
text=True,
encoding="utf-8",
errors="replace",
timeout=5,
)
@@ -1328,6 +1338,8 @@ class Gluetun(Proxy):
["docker", "rm", "-f", container_name],
capture_output=True,
text=True,
encoding="utf-8",
errors="replace",
timeout=10,
)
return True
@@ -1346,6 +1358,8 @@ class Gluetun(Proxy):
["docker", "rm", "-f", container_name],
capture_output=True,
text=True,
encoding="utf-8",
errors="replace",
timeout=10,
)
else:
@@ -1354,6 +1368,8 @@ class Gluetun(Proxy):
["docker", "stop", container_name],
capture_output=True,
text=True,
encoding="utf-8",
errors="replace",
timeout=10,
)
except subprocess.TimeoutExpired:
@@ -1363,6 +1379,8 @@ class Gluetun(Proxy):
["docker", "rm", "-f", container_name],
capture_output=True,
text=True,
encoding="utf-8",
errors="replace",
timeout=5,
)
except subprocess.TimeoutExpired:
+2 -2
View File
@@ -35,7 +35,7 @@ class Hola(Proxy):
p = subprocess.check_output(
[self.binary, "-country", query, "-list-proxies"], stderr=subprocess.STDOUT
).decode()
).decode("utf-8", errors="replace")
if "Transaction error: temporary ban detected." in p:
raise ConnectionError("Hola banned your IP temporarily from it's services. Try change your IP.")
@@ -55,6 +55,6 @@ class Hola(Proxy):
def get_countries(self) -> list[dict[str, str]]:
"""Get a list of available Countries."""
p = subprocess.check_output([self.binary, "-list-countries"]).decode("utf8")
p = subprocess.check_output([self.binary, "-list-countries"]).decode("utf-8", errors="replace")
return [{code: name} for country in p.splitlines() for (code, name) in [country.split(" - ", maxsplit=1)]]