Opened 6 years ago

Closed 6 years ago

Last modified 4 years ago

#10094 closed (fixed)

include and extends template tags do not accept filenames with spaces

Reported by: peter@… Owned by: gwilson
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 6 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 6 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 6 years ago by jacob

  • milestone set to 1.1
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 6 years ago by russellm

  • Component changed from Uncategorized to Template system

comment:4 Changed 6 years ago by mcroydon

  • Owner changed from nobody to mcroydon
  • Status changed from new to assigned

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

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

comment:5 Changed 6 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 6 years ago by anonymous

  • Owner changed from mcroydon to nobody
  • Status changed from assigned to 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:7 Changed 6 years ago by mcroydon

Sorry, the previous message was from me.

comment:8 Changed 6 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 6 years ago by jacob

  • Triage Stage changed from Accepted to Ready for checkin

comment:10 Changed 6 years ago by gwilson

  • Owner changed from nobody to gwilson
  • Status changed from new to assigned

comment:11 Changed 6 years ago by gwilson

  • Summary changed from do_extenbds function incorrectly parses Token to include and extends template tags do not accept filenames with spaces

comment:12 Changed 6 years ago by gwilson

  • Resolution set to fixed
  • Status changed from assigned to closed

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

comment:13 Changed 6 years ago by gwilson

(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 4 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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