diff --git a/falcon/response.py b/falcon/response.py index db9c8f474..691ddc893 100644 --- a/falcon/response.py +++ b/falcon/response.py @@ -675,7 +675,7 @@ def delete_header(self, name): # NOTE(kgriffs): normalize name by lowercasing it name = name.lower() - if name == 'set-cookie': + if name == 'set-cookie': raise HeaderNotSupported('This method cannot be used to remove cookies') self._headers.pop(name, None) @@ -769,7 +769,7 @@ def set_headers(self, headers): value = str(value) name = name.lower() - if name == 'set-cookie': + if name == 'set-cookie': raise HeaderNotSupported('This method cannot be used to set cookies') _headers[name] = value diff --git a/falcon/util/uri.py b/falcon/util/uri.py index 2a06dd8bb..0cc11b858 100644 --- a/falcon/util/uri.py +++ b/falcon/util/uri.py @@ -82,9 +82,9 @@ def encoder(uri, check_is_escaped=False): if check_is_escaped and not uri.rstrip(allowed_chars_plus_percent): # NOTE(kgriffs): There's a good chance the string has already # been escaped. Do one more check to increase our certainty. - # NOTE(minesja): Per issue #1872, there's only certain situations - # in which we should check again (ex. location, content_location, - # append_link).In all other cases we should allow characters that + # NOTE(minesja): Per issue #1872, there's only certain situations + # in which we should check again (ex. location, content_location, + # append_link).In all other cases we should allow characters that # could appear escaped to still be encoded (ex. '%' would be encoded # as '%25). tokens = uri.split('%') diff --git a/tests/test_utils.py b/tests/test_utils.py index 9c692a1f3..7d365c0aa 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -226,12 +226,11 @@ def test_uri_encode(self): # NOTE(minesja): Addresses #1872 assert uri.encode('%26') == '%2526' - assert uri.decode(uri.encode('%26') == '%26') + assert uri.decode(uri.encode('%26')) == '%26' def test_uri_encode_double(self): - # NOTE(minesja): check_is_escaped added to address maintain - # ignoring escaped values (addresses #68) while also - # addressing #1872 which should escape all values by default + # NOTE(minesja): check_is_escaped added to allow option to + # retain behavior of ignoring already escaped values (#68) url = 'http://example.com/v1/fiz bit/messages' expected = 'http://example.com/v1/fiz%20bit/messages' assert uri.encode(uri.encode(url), check_is_escaped=True) == expected @@ -268,7 +267,7 @@ def test_uri_encode_value(self): assert uri.encode_value('\u00e7\u20ac') == '%C3%A7%E2%82%AC' assert uri.encode_value('ab/cd') == 'ab%2Fcd' assert uri.encode_value('ab+cd=42,9') == 'ab%2Bcd%3D42%2C9' - + # NOTE(minesja): Addresses #1872 assert uri.encode_value('%26') == '%2526' assert uri.decode(uri.encode_value('%26')) == '%26'