Permalink
Browse files

unquote urls if percent encoded

  • Loading branch information...
1 parent aeb1426 commit b0066d08cac46dcd6064f202b8119bb6f85df884 @harryf committed Jun 24, 2008
Showing with 40 additions and 1 deletion.
  1. +0 −1 TODO
  2. +37 −0 dammit/webtests.py
  3. +3 −0 urldammit.py
View
@@ -1,6 +1,5 @@
- Character set handling frontend (allow UTF-8 only for now)
- Limits on input sizes - define constants
-- Implement PUT
- access control on senstive HTTP operations e.g. PUT, DELETE
- db implementations:
- couchdb (done)
View
@@ -138,6 +138,43 @@ def testHEAD(self):
self.assert_( content.strip() == '' )
@Report
+ def testPUT(self):
+ self.body['uri'] = 'http://foobar.com/%s.html'\
+ % sys._getframe().f_code.co_name
+ print self.body['uri']
+ response, content = self._post()
+ print response
+ self.assert_( response['status'] == '200' )
+ self.assert_( self.body['uri'] in content )
+
+ uri = response['content-location']
+
+ self._init_http()
+ self.body['status'] = '404'
+ response, content = self._post()
+ self.assert_( response['status'] == '404' )
+
+ self._init_http()
+ self.body['status'] = '301'
+ self.body['location'] = 'http://local.ch/foobar.html'
+ response, content = self._post()
+ self.assert_( response['status'] == '301' )
+ self.assert_( self.body['location'] in content )
+
+ self._init_http()
+ self.body['status'] = '200'
+ self.body['location'] = None
+ response, content = self.http.request(
+ uri, 'PUT',
+ headers=self.headers,
+ body=urllib.urlencode(self.body)
+ )
+ print response
+ self.assert_( response['status'] == '200' )
+ self.assert_( content.strip() == '' )
+
+
+ @Report
def testBadrequest(self):
self.body['uri'] = 'http://foobar.com/%s.html'\
% sys._getframe().f_code.co_name
View
@@ -253,6 +253,9 @@ def reduce_uri(i, uri):
uri to it's path (and left), if the object
i contains an attribute reduceurl
"""
+ if uri.startswith("http%3A%2F%2F"):
+ uri = urllib2.unquote(uri)
+
reduceurl = True
try:
reduceurl = getattr(i, 'reduceurl').lower() != 'false'

0 comments on commit b0066d0

Please sign in to comment.