Merge "reject problematic object names"
This commit is contained in:
commit
3b6dcfa467
@ -306,7 +306,8 @@ def check_utf8(string):
|
||||
if isinstance(string, unicode):
|
||||
string.encode('utf-8')
|
||||
else:
|
||||
string.decode('UTF-8')
|
||||
if string.decode('UTF-8').encode('UTF-8') != string:
|
||||
return False
|
||||
return '\x00' not in string
|
||||
# If string is unicode, decode() will raise UnicodeEncodeError
|
||||
# So, we should catch both UnicodeDecodeError & UnicodeEncodeError
|
||||
|
@ -416,6 +416,10 @@ class TestConstraints(unittest.TestCase):
|
||||
valid_utf8_str]:
|
||||
self.assertTrue(constraints.check_utf8(true_argument))
|
||||
|
||||
def test_check_utf8_non_canonical(self):
|
||||
self.assertFalse(constraints.check_utf8('\xed\xa0\xbc\xed\xbc\xb8'))
|
||||
self.assertFalse(constraints.check_utf8('\xed\xa0\xbd\xed\xb9\x88'))
|
||||
|
||||
def test_validate_bad_meta(self):
|
||||
req = Request.blank(
|
||||
'/v/a/c/o',
|
||||
|
Loading…
x
Reference in New Issue
Block a user