Issues #25232, #24657: Merge two CGI server fixes from 3.4 into 3.5
authorMartin Panter <vadmium+py@gmail.com>
Sat, 3 Oct 2015 06:03:25 +0000 (06:03 +0000)
committerMartin Panter <vadmium+py@gmail.com>
Sat, 3 Oct 2015 06:03:25 +0000 (06:03 +0000)
1  2 
Lib/http/server.py
Lib/test/test_httpservers.py
Misc/ACKS
Misc/NEWS

Simple merge
index 518e38ec3d11a89e33e3f56f3732715a7f1e21f8,6e5f2db7fdd36b88dacd3ef51752c0eddd74b073..50244c6ab1d51ab1460f3dde46343e1e545ec673
@@@ -602,10 -556,22 +620,23 @@@ class CGIHTTPServerTestCase(BaseTestCas
  
      def test_nested_cgi_path_issue21323(self):
          res = self.request('/cgi-bin/child-dir/file3.py')
 -        self.assertEqual((b'Hello World' + self.linesep, 'text/html', 200),
 -                (res.read(), res.getheader('Content-type'), res.status))
 +        self.assertEqual(
 +            (b'Hello World' + self.linesep, 'text/html', HTTPStatus.OK),
 +            (res.read(), res.getheader('Content-type'), res.status))
  
+     def test_query_with_multiple_question_mark(self):
+         res = self.request('/cgi-bin/file4.py?a=b?c=d')
+         self.assertEqual(
+             (b'a=b?c=d' + self.linesep, 'text/html', 200),
+             (res.read(), res.getheader('Content-type'), res.status))
+     def test_query_with_continuous_slashes(self):
+         res = self.request('/cgi-bin/file4.py?k=aa%2F%2Fbb&//q//p//=//a//b//')
+         self.assertEqual(
+             (b'k=aa%2F%2Fbb&//q//p//=//a//b//' + self.linesep,
+              'text/html', 200),
+             (res.read(), res.getheader('Content-type'), res.status))
  
  class SocketlessRequestHandler(SimpleHTTPRequestHandler):
      def __init__(self):
diff --cc Misc/ACKS
index 6999c0909c79202cd53c601dce1aec3da74535cb,9e2c57de7afd464d9bfbc882e77f9c6cdf78ea46..3b5f600cbfb8aea8bfdea46a49371d6e290f7c0a
+++ b/Misc/ACKS
@@@ -1577,9 -1529,9 +1577,10 @@@ Gordon Worle
  Darren Worrall
  Thomas Wouters
  Daniel Wozniak
 +Wei Wu
  Heiko Wundram
  Doug Wyatt
+ Xiang Zhang
  Robert Xiao
  Florent Xicluna
  Hirokazu Yamamoto
diff --cc Misc/NEWS
index 9a9b39bf2a75100ecc6c653c39c0cecea3ef5fa2,1c8bc491e656947f6171aa19eb7553a7afe1b66f..37b3d396b37563a6e429d96be22ffd9f9df8cc0f
+++ b/Misc/NEWS
@@@ -34,9 -90,12 +34,15 @@@ Core and Builtin
  Library
  -------
  
+ - Issue #25232: Fix CGIRequestHandler to split the query from the URL at the
+   first question mark (?) rather than the last. Patch from Xiang Zhang.
+ - Issue #24657: Prevent CGIRequestHandler from collapsing slashes in the
+   query part of the URL as if it were a path. Patch from Xiang Zhang.
 +- Issue #24483: C implementation of functools.lru_cache() now calculates key's
 +  hash only once.
 +
  - Issue #22958: Constructor and update method of weakref.WeakValueDictionary
    now accept the self and the dict keyword arguments.