Package: reportbug
Version: 13.0.1
Severity: minor
X-Debbugs-Cc: spa...@gmail.com

Dear Maintainer,

When submitting a bug on this package, the bugscript outputs a list of relevant
environment variables and their values. The output quotes the values, but does
not escape quotes within the values, leading to output that can look like this:

EXAMPLE="which "words" are "really" "quoted"?"

The attached patch uses the shlex python package to escape the values so the
output could be copied/pasted into a shell to reproduce the settings locally.
The new output only uses quotes when necessary. A version that always quotes,
and still performs appropriate escaping, is possible but would be more complex

This bug report was created using reportbug including the attached patch, and
the new formatting is visible in the "Package-specific info" section below.

-- Package-specific info:
** Environment settings:
EDITOR='code --wait'
VISUAL='code --wait'
DEBEMAIL=spa...@gmail.com
DEBFULLNAME='Clarence "Sparr" Risher'
INTERFACE=text

** /home/sparr/.reportbugrc:
reportbug_version "13.0.1"
mode novice
ui text
realname "Clarence \"Sparr\" Risher"
email "spa...@gmail.com"
no-cc
list-cc-me
smtphost reportbug.debian.org

-- System Information:
Architecture: amd64 (x86_64)

Kernel: Linux 6.10.10-arch1-1 (SMP w/12 CPU threads; PREEMPT)
Kernel taint flags: TAINT_WARN
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
diff --git a/share/script b/share/script
index e9b486c..b36e779 100755
--- a/share/script
+++ b/share/script
@@ -3,6 +3,7 @@
 
 import os
 import re
+import shlex
 
 OUT = os.fdopen(3, 'w', encoding='utf-8', errors='backslashreplace')
 
@@ -13,7 +14,7 @@ for var in ['EDITOR', 'PAGER', 'VISUAL', 'REPORTBUGEMAIL', 
'DEBEMAIL', 'EMAIL',
         if not envprint:
             print('** Environment settings:', file=OUT)
             envprint = True
-        print('%s="%s"' % (var, os.environ[var]), file=OUT)
+        print('%s=%s' % (var, shlex.quote(os.environ[var])), file=OUT)
 
 passwdre = re.compile(r'\s*(smtppasswd)\s+(.*)$')
 

Reply via email to