Code

Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#3733 closed (fixed)

django.utils.text.smart_split() does not properly handle unmatched quotes

Reported by: ivan.chelubeev@… Owned by: adrian
Component: Core (Other) Version: master
Severity: Keywords:
Cc: serg@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

django.utils.text.smart_split() does not properly handle unmatched quotes.

smart_split() eats up last character of the word that begins with an unmatched quote and that quote character itself:

>> text.smart_split("one 'two three")
['one', 'tw', 'three']

Of course unmatched quote in a tag argument string most probably is an error. But result produced by smart_split() ("'two" -> "tw") doesn't leave chances to notice or detect this error until actual use at render time (and may be even further).

Also smart_split()'s doctest still produce syntax error (in spite of #3035).

Attachments (1)

text-smart-split.patch (1.5 KB) - added by ivan.chelubeev@… 7 years ago.
fix for unmatched quote problem, with doctests

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by ivan.chelubeev@…

fix for unmatched quote problem, with doctests

comment:1 Changed 7 years ago by Simon G. <dev@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Ready for checkin

comment:2 Changed 7 years ago by mtredinnick

Thanks for this fix.

Tests should go in the tests/ directory. We don't run the docstrings in the main code, so the examples there are just examples. I've fixed this in this case -- and fixed up a small bug in one of the tests in passing. Merely pointing this out for next time.

comment:3 Changed 7 years ago by mtredinnick

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

(In [4870]) Fixed #3733 -- Fixed up quote parsing in smart_split(). Thanks, Ivan Chelubeev.

comment:4 Changed 6 years ago by anonymous

  • Cc serg@… added

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.