Ticket #2625: 2625.patch

File 2625.patch, 1.4 KB (added by truekonrads, 7 years ago)
  • twisted/python/urlpath.py

     
    6060        return self._pathMod(l, keepQuery)
    6161
    6262    def child(self, path, keepQuery=0):
     63        #Clean up path
     64        # 1) replace all / with urlescaped version
     65        # 2) escape the rest
     66        fixedPath=urllib.quote(path).replace('/','%2f')
    6367        l = self.pathList()
    6468        if l[-1] == '':
    65             l[-1] = path
     69            l[-1] = fixedPath
    6670        else:
    67             l.append(path)
     71            l.append(fixedPath)
    6872        return self._pathMod(l, keepQuery)
    6973
    7074    def parent(self, keepQuery=0):
  • twisted/test/test_paths.py

     
    831831        # here should be equivalent to '.'
    832832        self.assertEquals(str(self.path.here()), 'http://example.com/foo/')
    833833        self.assertEquals(str(self.path.child('').here()), 'http://example.com/foo/bar/')
     834       
     835    def test_childQuotes(self):
     836        #child() with quotes (",') and slashes  should be properly escaped
     837        self.assertEquals(str(self.path.child("hello/ there")),'http://example.com/foo/bar/hello%2f%20there')
    834838