Opened 8 years ago

Closed 3 years ago

#6535 closed Bug (fixed)

parser.compile_filter() does not support negative numbers

Reported by: Collin Grady <cgrady@…> Owned by: aaugustin
Component: Template system Version: master
Severity: Normal Keywords: tplrf-fixed
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no


After writing a patch for #5756, a new issue presented itself - another user tried {% ifequal -1 -1 %} and it threw a TemplateSyntaxError stating that it could not parse the remainder "-1"

A small tweak to a regex in django/template/ appears to correct the issue, but I'm not sure if a better change is needed along these lines to make it so the - can only be at the start of a number.

Attachments (1)

6535.patch (478 bytes) - added by Collin Grady <cgrady@…> 8 years ago.

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by Collin Grady <cgrady@…>

comment:1 Changed 7 years ago by jacob

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 7 years ago by emulbreh

  • Keywords tplrf-fixed added

This would be fixed by the refactoring proposed in #7806.

comment:3 Changed 5 years ago by julien

  • Type set to Bug

comment:4 Changed 4 years ago by julien

  • Severity set to Normal

comment:5 Changed 4 years ago by aaugustin

  • Easy pickings unset
  • Owner changed from nobody to aaugustin
  • UI/UX unset

comment:6 Changed 3 years ago by dirigeant

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

this issue already fixed.

s = "{% ifequal -1 -1 %}OK{% endifequal %}"
t = template.Template(s)
c = template.Context({})

r10169 | mtredinnick | 2009-03-25 03:45:56 +0000 (Çrş, 25 Mar 2009) | 5 lines
Template filters now pass numerical arguments through as numbers.

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