xfrs and auto-escaping documentation

58 views
Skip to first unread message

Antonio Pintus

unread,
Aug 6, 2012, 12:07:16 PM8/6/12
to Tornado Web Server
Hi,

in my opinion current Tornado documentation should be changed regarding xfrs sample in "overview" page.
In fact, examples refer to

If xsrf_cookies is set, the Tornado web application will set the _xsrf cookie for all users and reject all POSTPUT, and DELETE requests that do not contain a correct _xsrf value. If you turn this setting on, you need to instrument all forms that submit via POST to contain this field. You can do this with the special function xsrf_form_html(), available in all templates:

<form action="/new_message" method="post">
  {{ xsrf_form_html() }}
  <input type="text" name="message"/>
  <input type="submit" value="Post"/>
</form>

but auto-escaping now it's true by default, so examples,  should be written using {% raw xsrf_form_html() %}, shouldn't it?

Thank you,

Antonio





HENG

unread,
Aug 7, 2012, 11:33:22 AM8/7/12
to python-...@googlegroups.com
Use {% raw xsrf_form_html() %} is right ~ when autoescape=True~

2012/8/7 Antonio Pintus <pin...@gmail.com>



--
--------------------------------------------------------------------
HengZhou
---------------------------------------------------------------------
--

aliane abdelouahab

unread,
Aug 7, 2012, 12:59:03 PM8/7/12
to Tornado Web Server
yes, it should be modified, because auto escaping is by default ON.

Ben Darnell

unread,
Aug 11, 2012, 3:23:57 PM8/11/12
to python-...@googlegroups.com
Thanks, I've updated both places in the docs that still used the old form.

I used {% module %} instead of {% raw %} since xsrf_form_html is
registered as a module, and this way offers slightly less
encouragement to use {% raw %} frequently.

-Ben
Reply all
Reply to author
Forward
0 new messages