Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/utils_tests/test_safestring.py
Commit message (Collapse)AuthorAgeFilesLines
* Refs #24652 -- Used SimpleTestCase where appropriate.Simon Charette2015-05-201-2/+2
|
* Sorted imports with isort; refs #23860.Tim Graham2015-02-061-6/+6
|
* Fixed #23831 -- Supported strings escaped by third-party ↵Aymeric Augustin2014-12-271-4/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libs in Django. Refs #7261 -- Made strings escaped by Django usable in third-party libs. The changes in mark_safe and mark_for_escaping are straightforward. The more tricky part is to handle correctly objects that implement __html__. Historically escape() has escaped SafeData. Even if that doesn't seem a good behavior, changing it would create security concerns. Therefore support for __html__() was only added to conditional_escape() where this concern doesn't exist. Then using conditional_escape() instead of escape() in the Django template engine makes it understand data escaped by other libraries. Template filter |escape accounts for __html__() when it's available. |force_escape forces the use of Django's HTML escaping implementation. Here's why the change in render_value_in_context() is safe. Before Django 1.7 conditional_escape() was implemented as follows: if isinstance(text, SafeData): return text else: return escape(text) render_value_in_context() never called escape() on SafeData. Therefore replacing escape() with conditional_escape() doesn't change the autoescaping logic as it was originally intended. This change should be backported to Django 1.7 because it corrects a feature added in Django 1.7. Thanks mitsuhiko for the report.
* Fixed an inconsistency introduced in 547b1810.Aymeric Augustin2014-12-271-0/+18
| | | | | | | | mark_safe and mark_for_escaping should have been kept similar. On Python 2 this change has no effect. On Python 3 it fixes the use case shown in the regression test for mark_for_escaping, which used to raise a TypeError. The regression test for mark_safe is just for completeness.
* Fixed #20221 -- Allowed some functions that use ↵Jon Dufresne2014-10-201-0/+15
| | | | | | mark_safe() to result in SafeText. Thanks Baptiste Mispelon for the report.
* Removed import which is now unusedAlex Gaynor2014-02-051-1/+0
|
* Revert "Fixed #20296 -- Allowed SafeData and EscapeData ↵Baptiste Mispelon2014-02-051-11/+6
| | | | | | | | | | | | | to be lazy" This reverts commit 2ee447fb5f8974b432d3dd421af9a242215aea44. That commit introduced a regression (#21882) and didn't really do what it was supposed to: while it did delay the evaluation of lazy objects passed to mark_safe(), they weren't actually marked as such so they could end up being escaped twice. Refs #21882.
* Fixed #21302 -- Fixed unused imports and import *.Tim Graham2013-11-021-1/+0
|
* Fixed #7261 -- support for __html__ for library ↵Unai Zalakain2013-10-151-1/+5
| | | | | | | | | | interoperability The idea is that if an object implements __html__ which returns a string this is used as HTML representation (eg: on escaping). If the object is a str or unicode subclass and returns itself the object is a safe string type. This is an updated patch based on jbalogh and ivank patches.
* Removed most of absolute_import importsClaude Paroz2013-07-291-2/+1
| | | | | Should be unneeded with Python 2.7 and up. Added some unicode_literals along the way.
* Fixed #20296 -- Allowed SafeData and EscapeData to be lazyBaptiste Mispelon2013-05-251-0/+53