Force English locale for GPG verify to fix localized output parsing

Root cause: GPG outputs verification messages in the user's locale
(e.g., German "Gute Signatur von" instead of "Good signature from"),
causing the parsing logic to fail and display "Unknown signer".

Solution: Force LC_ALL=C and LANG=C environment variables when
calling 'gpg --verify' to ensure consistent English output across
all locales.

This ensures the code can reliably parse "Good signature from"
regardless of the user's system language settings.
This commit is contained in:
Claude
2025-12-14 13:55:26 +00:00
parent 62fa781350
commit f68c8389da

View File

@@ -43,12 +43,19 @@ class Crypto:
return False, "Not a GPG signed message"
try:
# Force English output for consistent parsing across locales
import os
env = os.environ.copy()
env['LC_ALL'] = 'C'
env['LANG'] = 'C'
proc = subprocess.Popen(
['gpg', '--verify'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
text=True,
env=env
)
stdout, stderr = proc.communicate(input=signed_content, timeout=10)