Opened 6 years ago

Closed 6 years ago

Last modified 4 years ago

#12072 closed (fixed)

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

Reported by: emulbreh 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 6 years ago.
Patch (maybe not pretty)
patch-12072-c.diff (4.1 KB) - added by alexdutton 6 years ago.
Tidier patch
patch-12072-d.diff (4.1 KB) - added by alexdutton 6 years ago.
Tidied up regex
patch-12072-e.diff (4.0 KB) - added by alexdutton 6 years ago.
Tidied up the regex even more

Download all attachments as: .zip

Change History (13)

comment:1 Changed 6 years ago by anonymous

  • Component changed from Uncategorized to Template system
  • Keywords url tag added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 6 years ago by russellm

  • milestone set to 1.2
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 6 years ago by eculver

  • Owner changed from nobody to eculver
  • Status changed from new to assigned

comment:4 Changed 6 years ago by eculver

  • Owner changed from eculver to nobody
  • Status changed from assigned to new

comment:5 Changed 6 years ago by alexdutton

  • Owner changed from nobody to alexdutton

Changed 6 years ago by alexdutton

Patch (maybe not pretty)

comment:6 Changed 6 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 6 years ago by alexdutton

Tidier patch

comment:7 Changed 6 years ago by alexdutton

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

Changed 6 years ago by alexdutton

Tidied up regex

Changed 6 years ago by alexdutton

Tidied up the regex even more

comment:8 Changed 6 years ago by jbronn

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

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

comment:9 Changed 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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