summaryrefslogtreecommitdiff
path: root/django/utils/text.py
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-03-30 11:57:50 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-03-30 11:57:50 +0000
commit5e739219de63328c13e14d60732ced4f28c033b9 (patch)
tree39eb9ae279384b99d898faf506b759d856197411 /django/utils/text.py
parent63a629bb8dd55a7976d7a71a93966f5e0c05ca5c (diff)
Fixed #3733 -- Fixed up quote parsing in smart_split(). Thanks, Ivan Chelubeev.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4870 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/text.py')
-rw-r--r--django/utils/text.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/django/utils/text.py b/django/utils/text.py
index faf8705fa9..e75abc5638 100644
--- a/django/utils/text.py
+++ b/django/utils/text.py
@@ -191,14 +191,15 @@ def smart_split(text):
Supports both single and double quotes, and supports escaping quotes with
backslashes. In the output, strings will keep their initial and trailing
quote marks.
- >>> list(smart_split('This is "a person\'s" test.'))
- ['This', 'is', '"a person\'s"', 'test.']
+
+ >>> list(smart_split('This is "a person\'s" test.'))
+ ['This', 'is', '"a person\'s"', 'test.']
"""
for bit in smart_split_re.finditer(text):
bit = bit.group(0)
- if bit[0] == '"':
+ if bit[0] == '"' and bit[-1] == '"':
yield '"' + bit[1:-1].replace('\\"', '"').replace('\\\\', '\\') + '"'
- elif bit[0] == "'":
+ elif bit[0] == "'" and bit[-1] == "'":
yield "'" + bit[1:-1].replace("\\'", "'").replace("\\\\", "\\") + "'"
else:
yield bit