Django

Code

Ticket #10094 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

include and extends template tags do not accept filenames with spaces

Reported by: peter@monicol.co.uk Assigned to: gwilson
Milestone: 1.1 Component: Template system
Version: 1.0 Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

10094-loader_tags-split_contents.diff (2.4 kB) - added by mcroydon on 03/29/09 18:31:45.
Patch and tests to use token.split_contents() in include and extends tags.

Change History

01/22/09 04:49:47 changed by anonymous

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

02/27/09 13:38:08 changed by jacob

  • stage changed from Unreviewed to Accepted.
  • milestone set to 1.1.

03/14/09 00:15:09 changed by russellm

  • component changed from Uncategorized to Template system.

03/29/09 18:16:41 changed 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.

03/29/09 18:31:45 changed by mcroydon

  • attachment 10094-loader_tags-split_contents.diff added.

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

03/29/09 18:36:39 changed by mcroydon

  • has_patch set to 1.

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.

03/29/09 22:34:44 changed 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.

03/29/09 23:29:03 changed by mcroydon

Sorry, the previous message was from me.

03/30/09 00:02:13 changed 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.

03/30/09 11:23:47 changed by jacob

  • stage changed from Accepted to Ready for checkin.

03/30/09 15:17:56 changed by gwilson

  • owner changed from nobody to gwilson.
  • status changed from new to assigned.

03/30/09 15:27:37 changed by gwilson

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

03/30/09 15:30:29 changed by gwilson

  • status changed from assigned to closed.
  • resolution set to fixed.

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

03/30/09 15:33:43 changed 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.


Add/Change #10094 (include and extends template tags do not accept filenames with spaces)




Change Properties
Action