summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2008-12-04 19:24:50 (GMT)
committerFred Drake <fdrake@acm.org>2008-12-04 19:24:50 (GMT)
commit9a0a65b524fa5afa91d918977bada03d24f95234 (patch)
tree37c46791a36fe961a93c3a6e0aa9462de21590da /Lib/test
parentc47408acc10f13869ba18bbbc311276fab24ce18 (diff)
downloadcpython-9a0a65b524fa5afa91d918977bada03d24f95234.zip
cpython-9a0a65b524fa5afa91d918977bada03d24f95234.tar.gz
cpython-9a0a65b524fa5afa91d918977bada03d24f95234.tar.bz2
Merged revisions 67528 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r67528 | fred.drake | 2008-12-04 13:25:17 -0500 (Thu, 04 Dec 2008) | 4 lines Issue #1055234: cgi.parse_header(): Fixed parsing of header parameters to support unusual filenames (such as those containing semi-colons) in Content-Disposition headers. ........
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_cgi.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py
index 0c53d8f..87028b5 100644
--- a/Lib/test/test_cgi.py
+++ b/Lib/test/test_cgi.py
@@ -325,6 +325,33 @@ this is the content of the fake file
self.assertEqual([('a', 'A1'), ('b', 'B2'), ('B', 'B3')],
cgi.parse_qsl('a=A1&b=B2&B=B3'))
+ def test_parse_header(self):
+ self.assertEqual(
+ cgi.parse_header("text/plain"),
+ ("text/plain", {}))
+ self.assertEqual(
+ cgi.parse_header("text/vnd.just.made.this.up ; "),
+ ("text/vnd.just.made.this.up", {}))
+ self.assertEqual(
+ cgi.parse_header("text/plain;charset=us-ascii"),
+ ("text/plain", {"charset": "us-ascii"}))
+ self.assertEqual(
+ cgi.parse_header('text/plain ; charset="us-ascii"'),
+ ("text/plain", {"charset": "us-ascii"}))
+ self.assertEqual(
+ cgi.parse_header('text/plain ; charset="us-ascii"; another=opt'),
+ ("text/plain", {"charset": "us-ascii", "another": "opt"}))
+ self.assertEqual(
+ cgi.parse_header('attachment; filename="silly.txt"'),
+ ("attachment", {"filename": "silly.txt"}))
+ self.assertEqual(
+ cgi.parse_header('attachment; filename="strange;name"'),
+ ("attachment", {"filename": "strange;name"}))
+ self.assertEqual(
+ cgi.parse_header('attachment; filename="strange;name";size=123;'),
+ ("attachment", {"filename": "strange;name", "size": "123"}))
+
+
def test_main():
run_unittest(CgiTests)