Index: Lib/cookielib.py =================================================================== --- Lib/cookielib.py (revision 66050) +++ Lib/cookielib.py (working copy) @@ -1464,6 +1464,10 @@ else: path_specified = False path = request_path(request) + # Strip off parameters after ? as they can contain /s + i = path.rfind("?") + if i != -1: + path = path[:i] i = path.rfind("/") if i != -1: if version == 0: Index: Lib/test/test_cookielib.py =================================================================== --- Lib/test/test_cookielib.py (revision 66050) +++ Lib/test/test_cookielib.py (working copy) @@ -533,6 +533,13 @@ 'eggs="bar"; Version="1"') self.assert_("/blah/rhubarb/" in c._cookies["www.acme.com"]) + # Test for http://bugs.python.org/issue3704. + # The query string should be ignored. + c = CookieJar(pol) + interact_2965(c, "http://www.acme.com/blah?err=/base/error.html&z=3", + 'eggs="bar"; Version="1"') + self.assert_("/" in c._cookies["www.acme.com"]) + # Netscape c = CookieJar()