Opened 5 years ago

Closed 5 years ago

#17660 closed Bug (fixed)

extends template tag mishandles filter expressions

Reported by: FunkyBob Owned by: nobody
Component: Template system Version: master
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 5 years ago.
17660a.patch (2.9 KB) - added by FunkyBob 5 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@…> 5 years ago.
test
17660_doc.patch (727 bytes) - added by FunkyBob 5 years ago.
Release notes doc patch
17660a_docs.patch (828 bytes) - added by FunkyBob 5 years ago.
Updated docs patch

Download all attachments as: .zip

Change History (11)

Changed 5 years ago by FunkyBob

Attachment: 17660.patch added

comment:1 Changed 5 years ago by FunkyBob

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

comment:2 Changed 5 years ago by Chris Beaven

Triage Stage: UnreviewedAccepted

comment:3 Changed 5 years ago by Chris Beaven

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 Changed 5 years ago by Chris Beaven

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

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

Changed 5 years ago by FunkyBob

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.

Changed 5 years ago by Bradley Ayers <bradley.ayers@…>

Attachment: 17660-test.patch added

test

Changed 5 years ago by FunkyBob

Attachment: 17660_doc.patch added

Release notes doc patch

comment:5 Changed 5 years ago by Chris Beaven

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

Changed 5 years ago by FunkyBob

Attachment: 17660a_docs.patch added

Updated docs patch

comment:6 Changed 5 years ago by Chris Beaven

Resolution: fixed
Status: newclosed

In [17568]:

Fixed #17660 -- Standardize extends tag token parsing

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