diff -r 65f2c92ed079 Lib/http/server.py --- a/Lib/http/server.py Sun Jul 07 23:30:24 2013 +0200 +++ b/Lib/http/server.py Tue Jul 09 00:31:25 2013 +0800 @@ -788,6 +788,8 @@ # abandon query parameters path = path.split('?',1)[0] path = path.split('#',1)[0] + # See Issue17324 + trailing_slash = True if path.rstrip().endswith('/') else False path = posixpath.normpath(urllib.parse.unquote(path)) words = path.split('/') words = filter(None, words) @@ -797,6 +799,8 @@ head, word = os.path.split(word) if word in (os.curdir, os.pardir): continue path = os.path.join(path, word) + if trailing_slash: + path += '/' return path def copyfile(self, source, outputfile): diff -r 65f2c92ed079 Lib/test/test_httpservers.py --- a/Lib/test/test_httpservers.py Sun Jul 07 23:30:24 2013 +0200 +++ b/Lib/test/test_httpservers.py Tue Jul 09 00:31:25 2013 +0800 @@ -270,6 +270,9 @@ #constructs the path relative to the root directory of the HTTPServer response = self.request(self.tempdir_name + '/test') self.check_status_and_reason(response, 200, data=self.data) + # check for trailing "/" which should return 404. See Issue17324 + response = self.request(self.tempdir_name + '/test/') + self.check_status_and_reason(response, 404) response = self.request(self.tempdir_name + '/') self.check_status_and_reason(response, 200) response = self.request(self.tempdir_name)