django/tests/utils_tests
Aymeric Augustin 6d52f6f8e6 Fixed #23831 -- Supported strings escaped by third-party 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.
2014-12-27 18:02:34 +01:00
..
archives Fixed #22681 -- Made TarArchive recognize leading directories properly. 2014-06-03 12:00:33 -04:00
eggs
files Whitespace cleanup. 2013-10-10 16:49:20 -04:00
locale/nl/LC_MESSAGES Fixed #9523 -- Restart runserver after translation MO files change 2013-11-02 10:29:07 +01:00
test_module Fixed #23670 -- Prevented partial import state during module autodiscovery 2014-10-31 08:01:47 -04:00
__init__.py
models.py Fixed #20094 - Be more careful when checking for Iterator 2013-03-22 17:31:29 +01:00
test_archive.py Fixed #22681 -- Made TarArchive recognize leading directories properly. 2014-06-03 12:00:33 -04:00
test_autoreload.py Fixed test failure on Windows. 2014-07-30 14:31:59 -04:00
test_baseconv.py Fixed #23812 -- Changed django.utils.six.moves.xrange imports to range 2014-12-13 12:45:58 -05:00
test_checksums.py Fixed #23613 -- Deprecated django.utils.checksums 2014-10-10 09:22:20 -04:00
test_crypto.py Fixed #21302 -- Fixed unused imports and import *. 2013-11-02 15:24:56 -04:00
test_datastructures.py Fixed #23620 -- Used more specific assertions in the Django test suite. 2014-11-03 11:56:37 -05:00
test_dateformat.py Fixed #21756 -- Skipped two timezone-related tests on Windows. 2014-01-12 09:41:57 +01:00
test_dateparse.py Fixed #2443 -- Added DurationField. 2014-12-20 18:28:29 +00:00
test_datetime_safe.py Fixed #23998 -- Added datetime.time support to migrations questioner. 2014-12-22 07:24:54 -05:00
test_decorators.py Fixing E302 Errors 2013-11-02 23:48:47 -05:00
test_duration.py Fixed #2443 -- Added DurationField. 2014-12-20 18:28:29 +00:00
test_encoding.py Fixed #18456 -- Added path escaping to HttpRequest.get_full_path(). 2014-11-03 07:59:19 -05:00
test_feedgenerator.py Refactored code and tests that relied on django.utils.tzinfo. 2013-09-09 22:32:52 +02:00
test_functional.py Fixed #23346 -- Fixed lazy() to lookup methods on the real object, not resultclasses. 2014-12-26 11:30:34 -05:00
test_html.py Removed redundant numbered parameters from str.format(). 2014-12-03 14:27:38 -05:00
test_http.py Fixed #23620 -- Used more specific assertions in the Django test suite. 2014-11-03 11:56:37 -05:00
test_ipv6.py Fixing E302 Errors 2013-11-02 23:48:47 -05:00
test_itercompat.py Modified utils_tests for unittest2 discovery. 2013-04-12 15:31:58 -06:00
test_jslex.py Fixed remaining test failure in jslex tests. 2014-10-15 17:36:19 +02:00
test_lazyobject.py Fixed #23620 -- Used more specific assertions in the Django test suite. 2014-11-03 11:56:37 -05:00
test_lorem_ipsum.py Fixed #22789 -- Deprecated django.contrib.webdesign. 2014-07-14 08:45:19 -04:00
test_module_loading.py Fixed #23670 -- Prevented partial import state during module autodiscovery 2014-10-31 08:01:47 -04:00
test_no_submodule.py
test_numberformat.py Removed redundant numbered parameters from str.format(). 2014-12-03 14:27:38 -05:00
test_os_utils.py Removed redundant numbered parameters from str.format(). 2014-12-03 14:27:38 -05:00
test_regex_helper.py Stopped using django.utils.unittest in the test suite. 2013-07-01 14:29:33 +02:00
test_safestring.py Fixed #23831 -- Supported strings escaped by third-party libs in Django. 2014-12-27 18:02:34 +01:00
test_simplelazyobject.py Fixed #21840 -- Moved dunder methods from SimpleLazyObject to LazyObject. 2014-03-13 10:03:01 +01:00
test_termcolors.py Fixed E127 pep8 warnings. 2013-12-14 11:59:15 -05:00
test_text.py Refs #23947 -- Worked around a bug in Python that prevents deprecation warnings from appearing in tests. 2014-12-06 14:46:01 -05:00
test_timesince.py Fixed all E226 violations 2013-11-03 10:08:55 -08:00
test_timezone.py Fixed #23388 -- Made django.utils.timezone.override usable as a decorator 2014-08-31 09:03:53 +02:00
test_tree.py Fixed #22531 -- Added tree.Node.__repr__ and tests for the class. 2014-05-16 09:30:25 -04:00
test_tzinfo.py Fixed #21281 -- Made override_settings act at class level when used as a TestCase decorator. 2014-11-03 14:14:39 -05:00