Skip to content

Commit

Permalink
Merge branch 'fix-urinorm-path'
Browse files Browse the repository at this point in the history
  • Loading branch information
ziima committed Jul 8, 2020
2 parents 4b0cbbf + aba0333 commit 7d26c7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion openid/test/test_urinorm.py
Expand Up @@ -71,11 +71,17 @@ def test_path_percent_encoding(self):
self.assertEqual(urinorm('http://example.com/Λ'), 'http://example.com/%CE%9B')

def test_path_capitalize_percent_encoding(self):
self.assertEqual(urinorm('http://example.com/foo%2cbar'), 'http://example.com/foo%2Cbar')
self.assertEqual(urinorm('http://example.com/foo%3abar'), 'http://example.com/foo%3Abar')

def test_path_percent_decode_unreserved(self):
self.assertEqual(urinorm('http://example.com/foo%2Dbar%2dbaz'), 'http://example.com/foo-bar-baz')

def test_path_keep_sub_delims(self):
self.assertEqual(urinorm('http://example.com/foo+!bar'), 'http://example.com/foo+!bar')

def test_path_percent_decode_sub_delims(self):
self.assertEqual(urinorm('http://example.com/foo%2B%21bar'), 'http://example.com/foo+!bar')

def test_illegal_characters(self):
six.assertRaisesRegex(self, ValueError, 'Illegal characters in URI', urinorm, 'http://<illegal>.com/')

Expand Down
4 changes: 2 additions & 2 deletions openid/urinorm.py
Expand Up @@ -122,10 +122,10 @@ def urinorm(uri):
# This is hackish. `unquote` and `quote` requires `str` in both py27 and py3+.
if isinstance(path, str):
# Python 3 branch
path = quote(unquote(path))
path = quote(unquote(path), safe='/' + SUB_DELIMS)
else:
# Python 2 branch
path = quote(unquote(path.encode('utf-8'))).decode('utf-8')
path = quote(unquote(path.encode('utf-8')), safe=('/' + SUB_DELIMS).encode('utf-8')).decode('utf-8')

path = remove_dot_segments(path)
if not path:
Expand Down

0 comments on commit 7d26c7f

Please sign in to comment.