@@ -322,6 +322,7 @@ def setUp(self):
322322 self .parent_dir = tempfile .mkdtemp ()
323323 self .cgi_dir = os .path .join (self .parent_dir , 'cgi-bin' )
324324 os .mkdir (self .cgi_dir )
325+ self .nocgi_path = None
325326 self .file1_path = None
326327 self .file2_path = None
327328
@@ -342,6 +343,11 @@ def setUp(self):
342343 self .tearDown ()
343344 self .skipTest ("Python executable path is not encodable to utf-8" )
344345
346+ self .nocgi_path = os .path .join (self .parent_dir , 'nocgi.py' )
347+ with open (self .nocgi_path , 'w' ) as fp :
348+ fp .write (cgi_file1 % self .pythonexe )
349+ os .chmod (self .nocgi_path , 0o777 )
350+
345351 self .file1_path = os .path .join (self .cgi_dir , 'file1.py' )
346352 with open (self .file1_path , 'w' , encoding = 'utf-8' ) as file1 :
347353 file1 .write (cgi_file1 % self .pythonexe )
@@ -359,6 +365,8 @@ def tearDown(self):
359365 os .chdir (self .cwd )
360366 if self .pythonexe != sys .executable :
361367 os .remove (self .pythonexe )
368+ if self .nocgi_path :
369+ os .remove (self .nocgi_path )
362370 if self .file1_path :
363371 os .remove (self .file1_path )
364372 if self .file2_path :
@@ -415,6 +423,10 @@ def test_headers_and_content(self):
415423 self .assertEqual ((b'Hello World' + self .linesep , 'text/html' , 200 ),
416424 (res .read (), res .getheader ('Content-type' ), res .status ))
417425
426+ def test_issue19435 (self ):
427+ res = self .request ('///////////nocgi.py/../cgi-bin/nothere.sh' )
428+ self .assertEqual (res .status , 404 )
429+
418430 def test_post (self ):
419431 params = urllib .parse .urlencode (
420432 {'spam' : 1 , 'eggs' : 'python' , 'bacon' : 123456 })
0 commit comments