#10094 closed (fixed)
include and extends template tags do not accept filenames with spaces
Reported by: | Owned by: | Gary Wilson | |
---|---|---|---|
Component: | Template system | Version: | 1.0 |
Severity: | 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
In module template.loader.tags the do_extends function parses a tokens
content like this: bits = token.contents.split() which does not
work correctly if the extends path has a folder name with a space in it
(as one of mine did). I understand token.split_contents() should
be used.
Attachments (1)
Change History (15)
comment:1 by , 16 years ago
comment:2 by , 16 years ago
milestone: | → 1.1 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 16 years ago
Component: | Uncategorized → Template system |
---|
comment:4 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
by , 16 years ago
Attachment: | 10094-loader_tags-split_contents.diff added |
---|
Patch and tests to use token.split_contents() in include and extends tags.
comment:5 by , 16 years ago
Has patch: | set |
---|
The patch above makes use of token.split_contents()
for both the include and extends tags, with tests that failed before the patch and now pass.
I left token.contents.split()
there for the block tag since allowing spaces in that tag ({% block 'my block' %
}) requires some design thought and might have side-effects that need to be thought about and tested. If we want to allow spaces in the block tag, that patch is trivial.
I may see if we can safely remove other instances of token.contents.split()
from django as well.
comment:6 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
The remaining calls to token.contents.split()
appear to be valid and moving to token.split_contents
might introduce unwanted changes. The above tags took arguments in strings whereas the remaining tags don't. It might be revisiting these at a later date for consistency.
comment:8 by , 16 years ago
This looks ready for checkin to me, but I'm erroring on the side of caution and not marking it as such so that it's given the proper attention by a committer.
comment:9 by , 16 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:10 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:11 by , 16 years ago
Summary: | do_extenbds function incorrectly parses Token → include and extends template tags do not accept filenames with spaces |
---|
comment:12 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
There are several places within django that are still using token.contents.split(). I'm working on changes and tests for
django.template.loader_tags
but there is other cleanup to be done as well.