| 27 | # Escaping. |
| 28 | |
| 29 | >>> flatatt({'onclick': script}) |
| 30 | u' onclick="$('#example').html('<a href="http://www.example.com/">example</a>');"' |
| 31 | >>> flatatt({'onclick': escape(script)}) |
| 32 | u' onclick="$('#example').html('<a href="http://www.example.com/">example</a>');"' |
| 33 | >>> flatatt({'onclick': conditional_escape(script)}) |
| 34 | u' onclick="$('#example').html('<a href="http://www.example.com/">example</a>');"' |
| 35 | |
| 36 | >>> conditional_escape(flatatt({'onclick': script})) |
| 37 | u' onclick="$('#example').html('<a href="http://www.example.com/">example</a>');"' |
| 38 | >>> conditional_escape(flatatt({'onclick': escape(script)})) |
| 39 | u' onclick="$('#example').html('<a href="http://www.example.com/">example</a>');"' |
| 40 | >>> conditional_escape(flatatt({'onclick': conditional_escape(script)})) |
| 41 | u' onclick="$('#example').html('<a href="http://www.example.com/">example</a>');"' |
| 42 | |
| 73 | |
| 74 | # Escaping. |
| 75 | |
| 76 | >>> print ValidationError(script).messages |
| 77 | <ul class="errorlist"><li>$('#example').html('<a href="http://www.example.com/">example</a>');</li></ul> |
| 78 | >>> print ValidationError(escape(script)).messages |
| 79 | <ul class="errorlist"><li>$('#example').html('<a href="http://www.example.com/">example</a>');</li></ul> |
| 80 | >>> print ValidationError(conditional_escape(script)).messages |
| 81 | <ul class="errorlist"><li>$('#example').html('<a href="http://www.example.com/">example</a>');</li></ul> |
| 82 | >>> print ErrorDict({'example': ValidationError(script).messages}) |
| 83 | <ul class="errorlist"><li>example<ul class="errorlist"><li>$('#example').html('<a href="http://www.example.com/">example</a>');</li></ul></li></ul> |
| 84 | >>> print ErrorDict({'example': ValidationError(escape(script)).messages}) |
| 85 | <ul class="errorlist"><li>example<ul class="errorlist"><li>$('#example').html('<a href="http://www.example.com/">example</a>');</li></ul></li></ul> |
| 86 | >>> print ErrorDict({'example': ValidationError(conditional_escape(script)).messages}) |
| 87 | <ul class="errorlist"><li>example<ul class="errorlist"><li>$('#example').html('<a href="http://www.example.com/">example</a>');</li></ul></li></ul> |
| 88 | |
| 89 | >>> print conditional_escape(unicode(ValidationError(script).messages)) |
| 90 | <ul class="errorlist"><li>$('#example').html('<a href="http://www.example.com/">example</a>');</li></ul> |
| 91 | >>> print conditional_escape(unicode(ValidationError(escape(script)).messages)) |
| 92 | <ul class="errorlist"><li>$('#example').html('<a href="http://www.example.com/">example</a>');</li></ul> |
| 93 | >>> print conditional_escape(unicode(ValidationError(conditional_escape(script)).messages)) |
| 94 | <ul class="errorlist"><li>$('#example').html('<a href="http://www.example.com/">example</a>');</li></ul> |
| 95 | >>> print conditional_escape(unicode(ErrorDict({'example': ValidationError(script).messages}))) |
| 96 | <ul class="errorlist"><li>example<ul class="errorlist"><li>$('#example').html('<a href="http://www.example.com/">example</a>');</li></ul></li></ul> |
| 97 | >>> print conditional_escape(unicode(ErrorDict({'example': ValidationError(escape(script)).messages}))) |
| 98 | <ul class="errorlist"><li>example<ul class="errorlist"><li>$('#example').html('<a href="http://www.example.com/">example</a>');</li></ul></li></ul> |
| 99 | >>> print conditional_escape(unicode(ErrorDict({'example': ValidationError(conditional_escape(script)).messages}))) |
| 100 | <ul class="errorlist"><li>example<ul class="errorlist"><li>$('#example').html('<a href="http://www.example.com/">example</a>');</li></ul></li></ul> |
| 101 | |