Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#12072 closed (fixed)

Literal strings containing [,=] break {% url %}.

Reported by: Johannes Dollinger Owned by: alexdutton
Component: Template system Version: 1.1
Severity: Keywords: url tag
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

>>> Template('{% url view arg|join:"," %}')
...
TemplateSyntaxError: join requires 1 arguments, 0 provided
>>> Template('{% url view "==" %}')
...
TemplateSyntaxError: Could not parse the remainder: '="' from '="'

Attachments (4)

patch-12072.diff (5.5 KB) - added by alexdutton 7 years ago.
Patch (maybe not pretty)
patch-12072-c.diff (4.1 KB) - added by alexdutton 7 years ago.
Tidier patch
patch-12072-d.diff (4.1 KB) - added by alexdutton 7 years ago.
Tidied up regex
patch-12072-e.diff (4.0 KB) - added by alexdutton 7 years ago.
Tidied up the regex even more

Download all attachments as: .zip

Change History (13)

comment:1 Changed 7 years ago by anonymous

Component: UncategorizedTemplate system
Keywords: url tag added
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 7 years ago by Russell Keith-Magee

milestone: 1.2
Triage Stage: UnreviewedAccepted

comment:3 Changed 7 years ago by eculver

Owner: changed from nobody to eculver
Status: newassigned

comment:4 Changed 7 years ago by eculver

Owner: changed from eculver to nobody
Status: assignednew

comment:5 Changed 7 years ago by alexdutton

Owner: changed from nobody to alexdutton

Changed 7 years ago by alexdutton

Attachment: patch-12072.diff added

Patch (maybe not pretty)

comment:6 Changed 7 years ago by alexdutton

I've added some tests to highlight the issue, and also replaced the {% url %} argument parsing.

Previously it split on ',' and '=' regardless of whether they're in string literals.

Now using filter_re from django.template to cope with string literals.

Changed 7 years ago by alexdutton

Attachment: patch-12072-c.diff added

Tidier patch

comment:7 Changed 7 years ago by alexdutton

New (considerably shorter) patch, with much regex help from Honza.

Changed 7 years ago by alexdutton

Attachment: patch-12072-d.diff added

Tidied up regex

Changed 7 years ago by alexdutton

Attachment: patch-12072-e.diff added

Tidied up the regex even more

comment:8 Changed 7 years ago by jbronn

Resolution: fixed
Status: newclosed

(In [12503]) Fixed #12072 -- Certain characters no longer break url tag. Thanks, Alexander Dutton.

comment:9 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

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