Opened 8 years ago

Closed 8 years ago

Last modified 5 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: UI/UX:

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 8 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 Changed 8 years ago by anonymous

comment:2 Changed 8 years ago by Jacob

milestone: 1.1
Triage Stage: UnreviewedAccepted

comment:3 Changed 8 years ago by Russell Keith-Magee

Component: UncategorizedTemplate system

comment:4 Changed 8 years ago by mcroydon

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.

Changed 8 years ago by mcroydon

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

comment:5 Changed 8 years ago by mcroydon

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 Changed 8 years ago by anonymous

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 Changed 8 years ago by mcroydon

Sorry, the previous message was from me.

comment:8 Changed 8 years ago by mcroydon

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 Changed 8 years ago by Jacob

Triage Stage: AcceptedReady for checkin

comment:10 Changed 8 years ago by Gary Wilson

Owner: changed from nobody to Gary Wilson
Status: newassigned

comment:11 Changed 8 years ago by Gary Wilson

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

comment:12 Changed 8 years ago by Gary Wilson

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 Changed 8 years ago by Gary Wilson

(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 Changed 5 years ago by Jacob

milestone: 1.1

Milestone 1.1 deleted

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