| 1 | = Auto-Escaping Proposals = |
| 2 | |
| 3 | This is a list of the various Autoescaping proposals to protect against Cross-Site Scripting. See [wiki:AutoEscaping], [http://groups.google.com/group/django-developers/browse_thread/thread/206b0ba41c2229b7 django-dev] for discussion. |
| 4 | |
| 5 | If you want to vote for one of these alternatives, please choose the one that you would prefer and place your name after the '''Votes''' part. |
| 6 | |
| 7 | |
| 8 | == 1: Nothing == |
| 9 | |
| 10 | Let the developer deal with it. |
| 11 | |
| 12 | '''Pros''': |
| 13 | |
| 14 | * Backwards Compatible |
| 15 | * "Pure", |
| 16 | * Already implemented. yay! |
| 17 | |
| 18 | '''Cons''': |
| 19 | |
| 20 | * Prone to XSS, |
| 21 | |
| 22 | '''Votes''': |
| 23 | |
| 24 | |
| 25 | |
| 26 | == 2: A context Autoescape Toggle == |
| 27 | |
| 28 | "adding a new property to the Context class, called autoescape. This defaults to being set to True, but can be toggled either in view functions or by {% autoescape off %} blocks in templates. The VariableNode render() method then uses this context flag to decide if escaping should be performed or not". See [wiki:AutoEscaping] |
| 29 | |
| 30 | '''Pros''': |
| 31 | * Safe |
| 32 | * Easy for template author to toggle. |
| 33 | |
| 34 | '''Cons''': |
| 35 | * "Magic", |
| 36 | * will require some way of marking strings in Django as "escaped" |
| 37 | * will need lots of rewriting of existing templates |
| 38 | * Backwards Incompatible |
| 39 | |
| 40 | '''Votes''': |
| 41 | |
| 42 | |
| 43 | == 3: Add a "finalfilter" == |
| 44 | |
| 45 | Provide a {% finalfilter %} block tag to automatically add filters (for html escaping, |escape) to any variable tag defined within the block. See [wiki:AutoEscape%20alternative] |
| 46 | |
| 47 | '''Pros''': |
| 48 | * Safe |
| 49 | * Easy for template author to use. |
| 50 | * Backwards Compatible |
| 51 | * Allows use of other escapers as a finalfilter so not just HTML |
| 52 | |
| 53 | '''Cons''': |
| 54 | * What would be the default status? |
| 55 | |
| 56 | |
| 57 | '''Votes''': Simon G. |
| 58 | |