[Django] #36465: Variables containing dashes are now allowed by the parser

13 views
Skip to first unread message

Django

unread,
Jun 16, 2025, 12:01:54 PM6/16/25
to django-...@googlegroups.com
#36465: Variables containing dashes are now allowed by the parser
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Type: Bug
Status: new | Component: Template
| system
Version: dev | Severity: Release
| blocker
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
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
--
Ticket URL: <https://code.djangoproject.com/ticket/36465>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 16, 2025, 12:53:08 PM6/16/25
to django-...@googlegroups.com
#36465: Variables containing dashes are now allowed by the parser
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Hailey
| Johnson
Type: Bug | Status: assigned
Component: Template system | Version: dev
Severity: Release blocker | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hailey Johnson):

* owner: (none) => Hailey Johnson
* status: new => assigned

Comment:

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 :)
--
Ticket URL: <https://code.djangoproject.com/ticket/36465#comment:1>

Django

unread,
Jun 16, 2025, 12:53:48 PM6/16/25
to django-...@googlegroups.com
#36465: Variables containing dashes are now allowed by the parser
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Hailey
| Johnson
Type: Bug | Status: assigned
Component: Template system | Version: dev
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hailey Johnson):

* stage: Unreviewed => Accepted

--
Ticket URL: <https://code.djangoproject.com/ticket/36465#comment:2>

Django

unread,
Jun 16, 2025, 5:46:58 PM6/16/25
to django-...@googlegroups.com
#36465: Variables containing dashes are now allowed by the parser
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Hailey
| Johnson
Type: Bug | Status: assigned
Component: Template system | Version: dev
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hailey Johnson):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36465#comment:3>

Django

unread,
Jun 17, 2025, 4:24:09 AM6/17/25
to django-...@googlegroups.com
#36465: Variables containing dashes are now allowed by the parser
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Hailey
| Johnson
Type: Bug | Status: assigned
Component: Template system | Version: dev
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36465#comment:4>

Django

unread,
Jun 18, 2025, 8:04:50 AM6/18/25
to django-...@googlegroups.com
#36465: Variables containing dashes are now allowed by the parser
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Hailey
| Johnson
Type: Bug | Status: closed
Component: Template system | Version: dev
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"22506b2c162b34c4c45f748cf11ede75824a40cd" 22506b2]:
{{{#!CommitTicketReference repository=""
revision="22506b2c162b34c4c45f748cf11ede75824a40cd"
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.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36465#comment:5>
Reply all
Reply to author
Forward
0 new messages