Pete Zaitcev
unread,May 9, 2012, 4:02:52 PM5/9/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to paste...@googlegroups.com, Pete Zaitcev
Hello:
OpenStack Swift contains a build-time (unit) test that looks like this:
......
req = Request.blank('/sda1/p/a?%s=\xce' % param,
environ={'REQUEST_METHOD': 'GET'})
resp = self.controller.GET(req)
self.assertEquals(resp.status_int, 400)
req = Request.blank('/sda1/p/a?%s=\xce\xa9' % param,
environ={'REQUEST_METHOD': 'GET'})
resp = self.controller.GET(req)
self.assert_(resp.status_int in (204, 412), resp.status_int)
As you can see, a UTF-8 character in the first test is incomplete and
is supposed to throw an exception. But the second test should work.
The tests like these blow up:
Traceback (most recent call last):
File "/q/zaitcev/hail/swift-tip/test/unit/account/test_server.py", line 976, in test_params_utf8
resp = self.controller.GET(req)
File "/q/zaitcev/hail/swift-tip/swift/account/server.py", line 220, in GET
req.accept = 'application/%s' % query_format.lower()
File "/usr/lib/python2.6/site-packages/webob/request.py", line 1173, in __setattr__
object.__setattr__(self, attr, value)
File "/usr/lib/python2.6/site-packages/webob/acceptparse.py", line 354, in fset
val = str(val)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u03c9' in position 12: ordinal not in range(128)
So, two questions:
1. Is it legal to supply a query string with parameters encoded this way?
2. Any recommendations as to how to deal with applications that do it?
Thanks,
-- Pete