Opened 4 years ago

Closed 4 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 4 years ago.
17660a.patch (2.9 KB) - added by FunkyBob 4 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@…> 4 years ago.
test
17660_doc.patch (727 bytes) - added by FunkyBob 4 years ago.
Release notes doc patch
17660a_docs.patch (828 bytes) - added by FunkyBob 4 years ago.
Updated docs patch

Download all attachments as: .zip

Change History (11)

Changed 4 years ago by FunkyBob

comment:1 Changed 4 years ago by FunkyBob

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

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

comment:2 Changed 4 years ago by SmileyChris

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 4 years ago by SmileyChris

  • 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 4 years ago by SmileyChris

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

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

Changed 4 years ago by FunkyBob

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

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

test

Changed 4 years ago by FunkyBob

Release notes doc patch

comment:5 Changed 4 years ago by SmileyChris

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

Changed 4 years ago by FunkyBob

Updated docs patch

comment:6 Changed 4 years ago by SmileyChris

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

In [17568]:

Fixed #17660 -- Standardize extends tag token parsing

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