I have tried xmlescape(response.flash).replace('\n','') Yes, this solves the problems. Would be nice to have it in trunk.
Thank you! 2012/8/4 Anthony <abasta...@gmail.com> > I see. I think the problem is only with response.flash within Ajax > components. The message is escaped on the server via urllib2.quote, and > then decoded in the browser via decodeURIComponent (see source > code<http://code.google.com/p/web2py/source/browse/applications/welcome/static/js/web2py.js#100> > ): > > jQuery('.flash').html(decodeURIComponent(flash)).slideDown(); > > The problem is that if there are any ascii encodings in flash, > decodeURIComponent seems to expect a valid URI and throws an error > otherwise, which is what is happening when the unicode characters are > included. A previous version of web2py.js did the escaping in Javascript on > the client side, but with the same effect. > > A fix might be to use xmlescape() to do any escaping on the server side > (which is effectively the same as the escaping of a regular flash message), > and then don't do any escaping or decoding on the client side -- so the > above line would change to: > > jQuery('.flash').html(flash).slideDown(); > > To do the server-side escaping, I think we can change line > 552<http://code.google.com/p/web2py/source/browse/gluon/main.py#552>in > main.py from: > > urllib2.quote(str(response.flash).replace('\n','')) > > to: > > xmlescape(response.flash).replace('\n','') > > (Would also have to import xmlescape from html.py.) > > Anthony > > --