Comment 1 for bug 180653

Revision history for this message
Anand Chitipothu (anandology) wrote : Re: [Bug 180653] web.form inputs fails when value parameter contains unicode data

> Workaround:
>
> edit form.py
> line 33: out += "<td>"+i.pre+i.render()+i.post+"</td>"
> change to:
> line 33: out += "<td>"+i.pre+i.render().decode('utf-8')+i.post+"</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'
--- 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(self.note)
         out += '<table>\n'
         for i in self.inputs:
- out += ' <tr><th><label for="%s">%s</label></th>' %
(i.id, i.description)
+ out += ' <tr><th><label for="%s">%s</label></th>' %
(i.id, net.websafe(i.description))
             out += "<td>"+i.pre+i.render()+i.post+"</td>"
             out += '<td id="note_%s">%s</td></tr>\n' % (i.id,
self.rendernote(i.note))
         out += "</table>"
         return out

     def rendernote(self, note):
- if note: return '<strong class="wrong">%s</strong>' % note
+ if note: return '<strong class="wrong">%s</strong>' % web.netsafe(note)
         else: return ""

     def validates(self, source=None, _validate=True, **kw):