summaryrefslogtreecommitdiff
path: root/cherrypy/test/test_http.py
diff options
context:
space:
mode:
authorAllan Crooks <allan@amcone.net>2014-04-15 14:08:54 -0400
committerAllan Crooks <allan@amcone.net>2014-04-15 14:08:54 -0400
commit47b8c33f685d3d132ac5893931dc07ced9056c09 (patch)
tree780108114c0ed1aca887306ef2757705ba82f8b5 /cherrypy/test/test_http.py
parent7d5b904a38d3de37e4b97cfec53685b23471d4ae (diff)
downloadcherrypy-git-47b8c33f685d3d132ac5893931dc07ced9056c09.tar.gz
Added posted-filename-with-commas test for #1146.
Diffstat (limited to 'cherrypy/test/test_http.py')
-rw-r--r--cherrypy/test/test_http.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/cherrypy/test/test_http.py b/cherrypy/test/test_http.py
index 5fb98ca0..a8c8933b 100644
--- a/cherrypy/test/test_http.py
+++ b/cherrypy/test/test_http.py
@@ -78,6 +78,11 @@ class HTTPTests(helper.CPWebCase):
summary.append("%s * %d" % (curchar, count))
return ", ".join(summary)
post_multipart.exposed = True
+
+ @cherrypy.expose
+ def post_filename(self, myfile):
+ '''Return the name of the file which was uploaded.'''
+ return myfile.filename
cherrypy.tree.mount(Root())
cherrypy.config.update({'server.max_request_body_size': 30000000})
@@ -135,6 +140,30 @@ class HTTPTests(helper.CPWebCase):
self.status = str(response.status)
self.assertStatus(200)
self.assertBody(", ".join(["%s * 65536" % c for c in alphabet]))
+
+ def test_post_filename_with_commas(self):
+ '''Testing that we can handle filenames with commas. This was
+ reported as a bug in:
+ https://bitbucket.org/cherrypy/cherrypy/issue/1146/'''
+ # We'll upload a bunch of files with differing names.
+ for fname in ['boop.csv', 'foo, bar.csv', 'bar, xxxx.csv']:
+ files = [('myfile', fname, 'yunyeenyunyue')]
+ content_type, body = encode_multipart_formdata(files)
+ body = body.encode('Latin-1')
+
+ # post file
+ c = self.make_connection()
+ c.putrequest('POST', '/post_filename')
+ c.putheader('Content-Type', content_type)
+ c.putheader('Content-Length', str(len(body)))
+ c.endheaders()
+ c.send(body)
+
+ response = c.getresponse()
+ self.body = response.fp.read()
+ self.status = str(response.status)
+ self.assertStatus(200)
+ self.assertBody(fname)
def test_malformed_request_line(self):
if getattr(cherrypy.server, "using_apache", False):