cpython: e4fe8fcaef0d (original) (raw)

Mercurial > cpython

changeset 86775:e4fe8fcaef0d 2.7

use the collapsed path in the run_cgi method (closes #19435) [#19435]

Benjamin Peterson benjamin@python.org
date Wed, 30 Oct 2013 12:43:09 -0400
parents bcbe4099206f
children dd12639b82bf 2d02b7a97e0b
files Lib/CGIHTTPServer.py Lib/test/test_httpservers.py Misc/NEWS
diffstat 3 files changed, 19 insertions(+), 5 deletions(-)[+] [-] Lib/CGIHTTPServer.py 9 Lib/test/test_httpservers.py 10 Misc/NEWS 5

line wrap: on

line diff

--- a/Lib/CGIHTTPServer.py +++ b/Lib/CGIHTTPServer.py @@ -105,18 +105,17 @@ class CGIHTTPRequestHandler(SimpleHTTPSe def run_cgi(self): """Execute a CGI script."""

scriptdir = self.translate_path(nextdir) if os.path.isdir(scriptdir): dir, rest = nextdir, nextrest

--- a/Lib/test/test_httpservers.py +++ b/Lib/test/test_httpservers.py @@ -396,6 +396,11 @@ class CGIHTTPServerTestCase(BaseTestCase else: self.pythonexe = sys.executable

+ self.file1_path = os.path.join(self.cgi_dir, 'file1.py') with open(self.file1_path, 'w') as file1: file1.write(cgi_file1 % self.pythonexe) @@ -414,6 +419,7 @@ class CGIHTTPServerTestCase(BaseTestCase os.chdir(self.cwd) if self.pythonexe != sys.executable: os.remove(self.pythonexe)

@@ -468,6 +474,10 @@ class CGIHTTPServerTestCase(BaseTestCase self.assertEqual(('Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status))

+ def test_post(self): params = urllib.urlencode({'spam' : 1, 'eggs' : 'python', 'bacon' : 123456}) headers = {'Content-type' : 'application/x-www-form-urlencoded'}

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -6,6 +6,11 @@ Whats' New in Python 2.7.6? Release date: 2013-11-02 +Library +------- + +- Issue #19435: Fix directory traversal attack on CGIHttpRequestHandler. + IDLE ----