Opened 18 years ago

Closed 18 years ago

Last modified 17 years ago

#3733 closed (fixed)

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

Reported by: ivan.chelubeev@… Owned by: Adrian Holovaty
Component: Core (Other) Version: dev
Severity: Keywords:
Cc: serg@… 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

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@… 18 years ago.
fix for unmatched quote problem, with doctests

Download all attachments as: .zip

Change History (5)

by ivan.chelubeev@…, 18 years ago

Attachment: text-smart-split.patch added

fix for unmatched quote problem, with doctests

comment:1 by Simon G. <dev@…>, 18 years ago

Triage Stage: UnreviewedReady for checkin

comment:2 by Malcolm Tredinnick, 18 years ago

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 by Malcolm Tredinnick, 18 years ago

Resolution: fixed
Status: newclosed

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

comment:4 by anonymous, 17 years ago

Cc: serg@… added
Note: See TracTickets for help on using tickets.
Back to Top