[Twisted-Python] Small diff for LivePage controller

Hi. I noticed that when my LivePage instance sends updates to DOM elements that are whitespace-sensitive, such as <pre> and <textarea wordwrap="off>, embedded newlines were getting stripped, leaving the element bodies as single text lines with some interword spacing removed. I tracked the problem down to this bit of code in woven/controller.py. The Javascript code generator is formatting the new element as a literal Javascript string which will be processed on the client side to modify the page. But by stripping out the newlines in the code we remove some important information in some HTML contexts. This patch leaves embedded newlines in the text, using JavaScript literal string escapes to make sure they get passed through OK. I also added string escaping for other legal special characters that have JS literal escapes. With this patch, LivePage is working really well for me! Thanks to all the folks who have given help on IRC. FWIW this patch is in the public domain. Bill Gribble Index: controller.py =================================================================== RCS file: /cvs/Twisted/twisted/web/woven/controller.py,v retrieving revision 1.60 diff -r1.60 controller.py 368,369d367 < nodeXML = nodeXML.replace('\n', '') < nodeXML = nodeXML.replace('\r', '') 371a370,378
participants (1)
-
Bill Gribble