#26536 closed Bug (fixed)
Stack overflow in template rendering when using django.template.loaders.cached.Loader
Reported by: | Anders Roos | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | 1.9 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If you have two template files with the same name except one is prefixed with a dash '-' where one is including the other, you will get a stack overflow.
For example if the main template named example.html
looks like this:
{% include '-example.html' %}
This bug is in django.template.loaders.cached.Loader and only happens if it is used.
I believe the bug is caused by the strip('-') when building the cache key at django/template/loaders/cached.py:103
(in Loader.cache_key
):
return ("%s-%s-%s" % (template_name, skip_prefix, dirs_prefix)).strip('-')
Change History (8)
comment:1 by , 9 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
This is a regression introduced by fc2147152637e21bc73f991b50fa06254af02739.
Using
'-'.join(filter(bool, [template_name, skip_prefix, dirs_prefix]))
instead should fix the issue.