#24461: Admin readonly_fields pointing to properties (@property) do not get
escaped.
-------------------------------+--------------------
Reporter: eranrund | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Hey,
My model has a @property, and I am using readonly_fields to display it.
allow_tags is nowhere to be seen, and I believe the culprit is the
following code (env/lib/python2.7/site-
packages/django/contrib/admin/helpers.py):
{{{
result_repr = smart_text(value)
if getattr(attr, "allow_tags", False):
result_repr = mark_safe(result_repr)
else:
result_repr = linebreaksbr(result_repr)
}}}
This is used by AdminReadonlyField to render the field. Unfortunately,
linebreaksbr replies on the template system autoescape mechanism, which
isn't kicking in when calling the filter directly:
{{{
In [2]: linebreaksbr('<a>test</a>')
Out[2]: u'<a>test</a>'
In [3]: type(_)
Out[3]: django.utils.safestring.SafeText
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24461>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.de5320b11f3631070b94be9c59ab0085%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.