Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#10094 closed (fixed)

include and extends template tags do not accept filenames with spaces

Reported by: peter@… 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)

10094-loader_tags-split_contents.diff (2.4 KB ) - added by mcroydon 16 years ago.
Patch and tests to use token.split_contents() in include and extends tags.

Download all attachments as: .zip

Change History (15)

comment:1 by anonymous, 16 years ago

comment:2 by Jacob, 16 years ago

milestone: 1.1
Triage Stage: UnreviewedAccepted

comment:3 by Russell Keith-Magee, 16 years ago

Component: UncategorizedTemplate system

comment:4 by mcroydon, 16 years ago

Owner: changed from nobody to mcroydon
Status: newassigned

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.

by mcroydon, 16 years ago

Patch and tests to use token.split_contents() in include and extends tags.

comment:5 by mcroydon, 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 anonymous, 16 years ago

Owner: changed from mcroydon to nobody
Status: assignednew

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:7 by mcroydon, 16 years ago

Sorry, the previous message was from me.

comment:8 by mcroydon, 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 Jacob, 16 years ago

Triage Stage: AcceptedReady for checkin

comment:10 by Gary Wilson, 16 years ago

Owner: changed from nobody to Gary Wilson
Status: newassigned

comment:11 by Gary Wilson, 16 years ago

Summary: do_extenbds function incorrectly parses Tokeninclude and extends template tags do not accept filenames with spaces

comment:12 by Gary Wilson, 16 years ago

Resolution: fixed
Status: assignedclosed

(In [10211]) Fixed #10094 -- Fixed the include and extends template tags to work with filenames with spaces, patch from mcroydon.

comment:13 by Gary Wilson, 16 years ago

(In [10212]) [1.0.X]: Fixed #10094 -- Fixed the include and extends template tags to work with filenames with spaces, patch from mcroydon.

Backport of r10211 from trunk.

comment:14 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top