[Python-bugs-list] [ python-Bugs-696846 ] CGIHTTPServer doesn't quote arguments correctly on Windows.

SourceForge.net noreply@sourceforge.net
Mon, 03 Mar 2003 13:06:17 -0800


Bugs item #696846, was opened at 2003-03-03 13:06
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=696846&group_id=5470

Category: Python Library
Group: Python 2.2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Allan B. Wilson (allanbwilson)
Assigned to: Nobody/Anonymous (nobody)
Summary: CGIHTTPServer doesn't quote arguments correctly on Windows.

Initial Comment:
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


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=696846&group_id=5470