Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#16677 closed Bug (fixed)

ssi template tag fails when the path to the template contains a space

Reported by: Aymeric Augustin Owned by: nobody
Component: Template system Version: 1.3
Severity: Normal 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 (last modified by Aymeric Augustin)

I initially noticed this problem here: http://ci.myks.org/job/Django%20+%20Oracle/42/console

Since the project is called "Django + Oracle", the checkout ends up in "/var/lib/jenkins/jobs/Django + Oracle/workspace", and there are spaces in the paths to the templates used by the tests.

To reproduce the problem, move your checkout of django so there's a space somewhere in the path (for instance mv django-trunk "django trunk") and run PYTHONPATH=.. ./runtests.py --settings=test_sqlite templates.

Apparently the current implementation of the ssi tag doesn't support spaces in the path to the template.

Attachments (2)

16677.patch (6.9 KB) - added by Aymeric Augustin 5 years ago.
16677.2.patch (7.5 KB) - added by Aymeric Augustin 5 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 5 years ago by Aymeric Augustin

The ssi tag is defined twice, in django/template/defaulttags.py and in django/templatetags/future.py. I recommend:

  • not changing the behavior of the "old" version, and just disable its tests when the path contains a space; all this code will be removed in Django 1.5 anyway.
  • fixing the "new" version by using token.split_contents() (quotes-aware spitting) instead of token.contents.split() (naïve splitting) to parse the content of the tag.

I think the second point is a real bug and I've added a test case for it — a template whose file name contains spaces.

Attached patch implements this.

comment:2 Changed 5 years ago by Aymeric Augustin

Description: modified (diff)
Summary: templates tests fail when the path to django contains a spacessi template tag fails when the path to the template contains a space

Changed 5 years ago by Aymeric Augustin

Attachment: 16677.patch added

comment:3 Changed 5 years ago by Julien Phalip

Has patch: set
Triage Stage: UnreviewedAccepted

Thanks for the report and fix! The patch looks good. However, why only fix the future version? I don't see why both versions shouldn't be fixed in 1.4.

Changed 5 years ago by Aymeric Augustin

Attachment: 16677.2.patch added

comment:4 Changed 5 years ago by Aymeric Augustin

Changes in the 2nd iteration of the patch:

  • two tests were added to check that it's still a TemplateSyntaxError to use spaces in the path to the template with the "old" ssi tag.
  • the tests of the "old" ssi tag are now changed to expect TemplateSyntaxError when the path to the Django checkout contains spaces, instead of just being removed.

comment:5 Changed 5 years ago by Julien Phalip

Triage Stage: AcceptedReady for checkin

Perfect, thank you!

comment:6 Changed 5 years ago by Julien Phalip

Resolution: fixed
Status: newclosed

In [16687]:

Fixed #16677 -- Fixed the future version of the ssi template tag to work with template file names that contain spaces. Note that this fix cannot be applied to the currently deprecated version of the ssi tag since it requires an unquoted literal as parameter. Many thanks to Aymeric Augustin for the report and patch.

comment:7 Changed 5 years ago by Aymeric Augustin

In [17804]:

[1.3.X] Fixed #16677 -- Fixed the future version of the ssi template tag to work with template file names that contain spaces. Backport of r16687 from trunk.

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