Opened 13 years ago

Closed 13 years ago

#17660 closed Bug (fixed)

extends template tag mishandles filter expressions

Reported by: FunkyBob Owned by: nobody
Component: Template system Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

For unknown reasons, the {% extends %} tag tries to manually identify string literals as the argument, by testing if they start and end with the same char, and that char is ' or "

This test fails with the following trivial case:

{% extends "something"|afilter:"else" %}

I can see little to no reason not to switch to using the same argument filtering as everyone else, except for the _tiny_ amount of extra debug information provided.

Attachments (5)

17660.patch (2.3 KB ) - added by FunkyBob 13 years ago.
17660a.patch (2.9 KB ) - added by FunkyBob 13 years ago.
After further discussion with SmileyChris, here is a patch which doesn't lose the extra debugging info, instead showing the actual expression used.
17660-test.patch (996 bytes ) - added by Bradley Ayers <bradley.ayers@…> 13 years ago.
test
17660_doc.patch (727 bytes ) - added by FunkyBob 13 years ago.
Release notes doc patch
17660a_docs.patch (828 bytes ) - added by FunkyBob 13 years ago.
Updated docs patch

Download all attachments as: .zip

Change History (11)

by FunkyBob, 13 years ago

Attachment: 17660.patch added

comment:1 by FunkyBob, 13 years ago

Fair's fair... it was bradleyayers who brought this bug to my attention... I just formulated the patch.

comment:2 by Chris Beaven, 13 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Chris Beaven, 13 years ago

Needs documentation: set
Needs tests: set

Needs a test and a quick note in the changes docs that the ExtendsNode definition changed (even though it's not documented, it's still a nice thing to mention)

comment:4 by Chris Beaven, 13 years ago

You could easily keep the "tiny bit of debugging" with this:

if self.parent_name.filters or isinstance(self.parent_name.var, Variable):

by FunkyBob, 13 years ago

Attachment: 17660a.patch added

After further discussion with SmileyChris, here is a patch which doesn't lose the extra debugging info, instead showing the actual expression used.

by Bradley Ayers <bradley.ayers@…>, 13 years ago

Attachment: 17660-test.patch added

test

by FunkyBob, 13 years ago

Attachment: 17660_doc.patch added

Release notes doc patch

comment:5 by Chris Beaven, 13 years ago

The notes should mention the change in arguments to the ExtendsNode for anyone who may have been extending/using it in their tag.

by FunkyBob, 13 years ago

Attachment: 17660a_docs.patch added

Updated docs patch

comment:6 by Chris Beaven, 13 years ago

Resolution: fixed
Status: newclosed

In [17568]:

Fixed #17660 -- Standardize extends tag token parsing

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