web.form inputs fails when value parameter contains unicode data
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
web.py |
Fix Released
|
High
|
Anand Chitipothu |
Bug Description
I'm getting this error (web.py 0.23 + Mako templates)
Traceback (most recent call last):
File "/home/
out += "<td>"+
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 48: ordinal not in range(128)
sample code:
...
address = list(web.
vars={
}
))
address_form = web.form.Form(
web.
...
Workaround:
edit form.py
line 33: out += "<td>"+
change to:
line 33: out += "<td>"+
Changed in webpy: | |
status: | Confirmed → Fix Committed |
Changed in webpy: | |
status: | Fix Committed → Fix Released |
> Workaround: i.pre+i. render( )+i.post+ "</td>" i.pre+i. render( ).decode( 'utf-8' )+i.post+ "</td>"
>
> edit form.py
> line 33: out += "<td>"+
> change to:
> line 33: out += "<td>"+
I think, the problem is not there. Problem is in adding the
description, which not websafe'd. The same problem may come, if you
have unicode error messages.
Here is the fix.
file 'web/form.py' (self.note) >%s</label> </th>' % >%s</label> </th>' % i.description) ) i.pre+i. render( )+i.post+ "</td>" %s">%s< /td></tr> \n' % (i.id, (i.note) )
--- web/form.py 2007-06-21 00:58:41 +0000
+++ web/form.py 2008-01-06 01:18:31 +0000
@@ -29,14 +29,14 @@
out += self.rendernote
out += '<table>\n'
for i in self.inputs:
- out += ' <tr><th><label for="%s"
(i.id, i.description)
+ out += ' <tr><th><label for="%s"
(i.id, net.websafe(
out += "<td>"+
out += '<td id="note_
self.rendernote
out += "</table>"
return out
def rendernote(self, note): wrong"> %s</strong> ' % note wrong"> %s</strong> ' % web.netsafe(note)
- if note: return '<strong class="
+ if note: return '<strong class="
else: return ""
def validates(self, source=None, _validate=True, **kw):