Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CGIHTTPServer doesn't quote arguments correctly on Windows. #38091

Closed
allanbwilson mannequin opened this issue Mar 3, 2003 · 3 comments
Closed

CGIHTTPServer doesn't quote arguments correctly on Windows. #38091

allanbwilson mannequin opened this issue Mar 3, 2003 · 3 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@allanbwilson
Copy link
Mannequin

allanbwilson mannequin commented Mar 3, 2003

BPO 696846
Nosy @akuchling

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/akuchling'
closed_at = <Date 2004-06-05.19:23:20.000>
created_at = <Date 2003-03-03.21:06:17.000>
labels = ['library']
title = "CGIHTTPServer doesn't quote arguments correctly on Windows."
updated_at = <Date 2004-06-05.19:23:20.000>
user = 'https://bugs.python.org/allanbwilson'

bugs.python.org fields:

activity = <Date 2004-06-05.19:23:20.000>
actor = 'akuchling'
assignee = 'akuchling'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2003-03-03.21:06:17.000>
creator = 'allanbwilson'
dependencies = []
files = []
hgrepos = []
issue_num = 696846
keywords = []
message_count = 3.0
messages = ['14925', '14926', '14927']
nosy_count = 3.0
nosy_names = ['akuchling', 'insomnike', 'allanbwilson']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue696846'
versions = ['Python 2.2']

@allanbwilson
Copy link
Mannequin Author

allanbwilson mannequin commented Mar 3, 2003

In module CGIHTTPServer.py, in the section containing
the following:

-----

    elif self.have_popen2 or self.have_popen3:
        \# Windows -- use popen2 or popen3 to create a 

subprocess
import shutil
if self.have_popen3:
popenx = os.popen3
else:
popenx = os.popen2
cmdline = scriptfile
if self.is_python(scriptfile):
interp = sys.executable
if interp.lower().endswith("w.exe"):
# On Windows, use python.exe, not
pythonw.exe
interp = interp[:-5] + interp[-4:]
cmdline = "%s -u %s" % (interp, cmdline)

-----

The final line, number 231 in my copy (version 0.4 in
Python 2.2.2), doesn't handle filespecs with embedded
spaces correctly. A script named, for example, "Powers
of two.py" won't be found. This can be fixed by changing
the quoting, namely to:

            cmdline = '%s -u "%s"' % (interp, cmdline)

so that the script name in cmdline is quoted properly.

Note that embedded spaces in interp could also cause
problems (if Python were installed in C:\Program Files\
for example), but though adding "s around the first %s
works for commands executed directly within Windows
XP's cmd.exe, I couldn't get os.popen3 to handle them.

Thanks for your help.

Allan Wilson

@allanbwilson allanbwilson mannequin closed this as completed Mar 3, 2003
@allanbwilson allanbwilson mannequin assigned akuchling Mar 3, 2003
@allanbwilson allanbwilson mannequin added the stdlib Python modules in the Lib dir label Mar 3, 2003
@allanbwilson allanbwilson mannequin closed this as completed Mar 3, 2003
@insomnike
Copy link
Mannequin

insomnike mannequin commented Jun 5, 2004

Logged In: YES
user_id=1057404

The above isn't safe, and if the command is devoid of '=' or
'"', it's run with quotes (in CVS HEAD as of 05/Jun/2004).

@akuchling
Copy link
Member

Logged In: YES
user_id=11375

Fixed in HEAD; closing.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant