Opened 17 years ago

Closed 12 years ago

#6535 closed Bug (fixed)

parser.compile_filter() does not support negative numbers

Reported by: Collin Grady <cgrady@…> Owned by: Aymeric Augustin
Component: Template system Version: dev
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

Description

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/__init__.py 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@…> 17 years ago.

Download all attachments as: .zip

Change History (7)

by Collin Grady <cgrady@…>, 17 years ago

Attachment: 6535.patch added

comment:1 by Jacob, 17 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted

comment:2 by Johannes Dollinger, 16 years ago

Keywords: tplrf-fixed added

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

comment:3 by Julien Phalip, 14 years ago

Type: Bug

comment:4 by Julien Phalip, 14 years ago

Severity: Normal

comment:5 by Aymeric Augustin, 13 years ago

Easy pickings: unset
Owner: changed from nobody to Aymeric Augustin
UI/UX: unset

comment:6 by Türker Sezer, 12 years ago

Resolution: fixed
Status: newclosed

this issue already fixed.

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

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