MCPcopy Index your code
hub / github.com/cherrypy/cherrypy / test_query_string_decoding

Method test_query_string_decoding

cherrypy/test/test_encoding.py:123–144  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

121 cherrypy.tree.mount(root, config={'/gzip': {'tools.gzip.on': True}})
122
123 def test_query_string_decoding(self):
124 URI_TMPL = '/reqparams?q={q}'
125
126 europoundUtf8_2_bytes = europoundUnicode.encode('utf-8')
127 europoundUtf8_2nd_byte = europoundUtf8_2_bytes[1:2]
128
129 # Encoded utf8 query strings MUST be parsed correctly.
130 # Here, q is the POUND SIGN U+00A3 encoded in utf8 and then %HEX
131 self.getPage(URI_TMPL.format(q=url_quote(europoundUtf8_2_bytes)))
132 # The return value will be encoded as utf8.
133 self.assertBody(b'q: ' + europoundUtf8_2_bytes)
134
135 # Query strings that are incorrectly encoded MUST raise 404.
136 # Here, q is the second byte of POUND SIGN U+A3 encoded in utf8
137 # and then %HEX
138 # TODO: check whether this shouldn't raise 400 Bad Request instead
139 self.getPage(URI_TMPL.format(q=url_quote(europoundUtf8_2nd_byte)))
140 self.assertStatus(404)
141 self.assertErrorPage(
142 404,
143 'The given query string could not be processed. Query '
144 "strings for this resource must be encoded with 'utf8'.")
145
146 def test_urlencoded_decoding(self):
147 # Test the decoding of an application/x-www-form-urlencoded entity.

Callers

nothing calls this directly

Calls 4

encodeMethod · 0.80
getPageMethod · 0.80
formatMethod · 0.80
assertErrorPageMethod · 0.80

Tested by

no test coverage detected