Opened 3 months ago

Closed 3 months ago

#36465 closed Bug (fixed)

Variables containing dashes are now allowed by the parser

Reported by: Baptiste Mispelon Owned by: Hailey Johnson
Component: Template system Version: dev
Severity: Release blocker Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This was originally reported in https://code.djangoproject.com/ticket/35816#comment:19

As noted in the link above, the fix for #35816 introduced was I believe to be an unintended side-effect to the parsing rules for variable names.

The documentation for variable names [1] states that:

Variable names consist of any combination of alphanumeric characters and the underscore ("_") but may not start with an underscore, and may not be a number. The dot (".") also appears in variable sections, although that has a special meaning, as indicated below. Importantly, you cannot have spaces or punctuation characters in variable names.

My understanding is that dashes (-) do not count as alphanumeric and should therefore not be allowed in a variable name.

[1] https://docs.djangoproject.com/en/dev/ref/templates/language/#variables

Change History (5)

comment:1 by Hailey Johnson, 3 months ago

Owner: set to Hailey Johnson
Status: newassigned

I'm relatively certain I already have a fix for this implemented somewhere, but we made a different decision on my original PR, I'll get a new one up asap :)

comment:2 by Hailey Johnson, 3 months ago

Triage Stage: UnreviewedAccepted

comment:3 by Hailey Johnson, 3 months ago

Has patch: set

comment:4 by Sarah Boyce, 3 months ago

Triage Stage: AcceptedReady for checkin

comment:5 by Sarah Boyce <42296566+sarahboyce@…>, 3 months ago

Resolution: fixed
Status: assignedclosed

In 22506b2:

Fixed #36465, Refs #35816 -- Disallowed '+' and '-' characters in template variable names.

Regression in 5183f7c287a9a5d61ca1103b55166cda52d9c647.

Thank you to Jon Banafato and Baptiste Mispelon for the report.

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