Opened 14 years ago
Last modified 14 years ago
#17135 closed Bug
stringfilter decorator is incompatible with is_safe / needs_autoescape flags — at Initial Version
| Reported by: | Aymeric Augustin | Owned by: | nobody |
|---|---|---|---|
| Component: | Template system | Version: | 1.3 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Defining a template filter like this doesn't work:
@register.filter
@stringfilter
def passthrough(value):
return value
passthrough.is_safe = True
The problem is that the stringfilter decorator keeps a pointer to the underlying function, and the template engine uses it.
However, the last line only sets is_safe on the function returned by the decorator, not on the underlying function. As a consequence, the template filter doesn't know that the filter is safe.
Note:
See TracTickets
for help on using tickets.