Commits

Ian Bicking committed 0fc2eb3

Fixed test case from Graham Dumpleton, where REQUEST_URI and SCRIPT_NAME/PATH_INFO just don't match up

  • Participants
  • Parent commits 1df5a12

Comments (0)

Files changed (2)

File request_uri.py

         qscript_name_parts, qpath_info_parts = request_uri_parts[:script_name_segments], request_uri_parts[script_name_segments:]
         remove_segments = sum(part.lower().count('%2f') for part in qscript_name_parts)
         while remove_segments:
+            if not qscript_name_parts:
+                # Something isn't matching up
+                if safe:
+                    return quote(script_name), quote(path_info)
+                else:
+                    return None
             remove_segments = remove_segments - 1 - qscript_name_parts[-1].lower().count('%2f')
             qpath_info_parts.insert(0, qscript_name_parts[-1])
             qscript_name_parts.pop()
 /foo%20bar/baz ->  + /foo%20bar/baz
 >>> t('/blahblah%2f/baz/foo', '/blahblah//baz', '/foo')
 /blahblah%2f/baz/foo -> /blahblah%2f/baz + /foo
+>>> t('/a%2fb/c/d', '/wsgi20.wsgi', '/a/b/c/d')
+No match
 """}
 
 if __name__ == '__main__':

File request_uri3.py

         qscript_name_parts, qpath_info_parts = request_uri_parts[:script_name_segments], request_uri_parts[script_name_segments:]
         remove_segments = sum(part.lower().count('%2f') for part in qscript_name_parts)
         while remove_segments:
+            if not qscript_name_parts:
+                # Something isn't matching up
+                if safe:
+                    return quote_from_bytes(script_name), quote_from_bytes(path_info)
+                else:
+                    return None
             remove_segments = remove_segments - 1 - qscript_name_parts[-1].lower().count('%2f')
             qpath_info_parts.insert(0, qscript_name_parts[-1])
             qscript_name_parts.pop()
 /foo%20bar/baz ->  + /foo%20bar/baz
 >>> t('/blahblah%2f/baz/foo', b'/blahblah//baz', b'/foo')
 /blahblah%2f/baz/foo -> /blahblah%2f/baz + /foo
+>>> t('/a%2fb/c/d', b'/wsgi20.wsgi', b'/a/b/c/d')
+No match
 """}
 
 if __name__ == '__main__':