django1/django
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
..
apps Improved warning message when reloading models. Refs #23621. 2014-10-23 01:46:04 +07:00
bin Started attackign the next flake8 violation 2013-10-31 08:42:28 -07:00
conf Fixed timesince translations for Korean 2014-12-14 16:48:42 +01:00
contrib Fixed #24000 -- Corrected contrib.sites default site creation in a multiple database setup. 2014-12-27 09:42:13 -05:00
core Replaced sqlall in some bash_completion/admin_scripts tests. 2014-12-26 18:52:26 -05:00
db Fixed #14180 -- Prevented unneeded index creation on MySQL-InnoDB 2014-12-27 12:52:44 +01:00
dispatch Fixed #23812 -- Changed django.utils.six.moves.xrange imports to range 2014-12-13 12:45:58 -05:00
forms Fixed #21414 -- Removed RelatedObject and deprecated Field.related. 2014-12-23 10:54:25 -05:00
http Fixed #23977 -- Added setdefault() method to HttpResponse 2014-12-11 13:56:56 -05:00
middleware Fixed #23531 -- Added CommonMiddleware.response_redirect_class. 2014-11-04 17:56:57 -05:00
template Fixed #23831 -- Supported strings escaped by third-party libs in Django. 2014-12-27 18:02:34 +01:00
templatetags Fixed #23968 -- Replaced list comprehension with generators and dict comprehension 2014-12-08 07:58:23 -05:00
test Fixed #20349 -- Moved setting_changed signal to django.core.signals. 2014-12-24 07:18:43 -05:00
utils Fixed #23831 -- Supported strings escaped by third-party libs in Django. 2014-12-27 18:02:34 +01:00
views Updated link to CSRF docs 2014-12-25 14:01:15 +01:00
__init__.py Simplified get_version() in django/__init__.py 2014-11-24 07:02:29 -05:00
shortcuts.py Moved relative URL handling added in refs #21177 to a better place. 2014-02-15 07:54:35 -05:00