mirror of
https://github.com/overcuriousity/trace.git
synced 2025-12-20 13:02:21 +00:00
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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user