Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #12119. Changed smart_split to stop splitting on whitespace in …

…quotes. Thanks, emulbreh.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12581 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c8cd8b80aa90f463814e1957d26e4a11f2f94414 1 parent 3304afa
Joseph Kocherhans authored
11  django/utils/text.py
@@ -202,9 +202,14 @@ def fix(match):
202 202
 # Expression to match some_token and some_token="with spaces" (and similarly
203 203
 # for single-quoted strings).
204 204
 smart_split_re = re.compile(r"""
205  
-    ([^\s"]*"(?:[^"\\]*(?:\\.[^"\\]*)*)"\S*|
206  
-     [^\s']*'(?:[^'\\]*(?:\\.[^'\\]*)*)'\S*|
207  
-     \S+)""", re.VERBOSE)
  205
+    ((?:
  206
+        [^\s'"]*
  207
+        (?:
  208
+            (?:"(?:[^"\\]|\\.)*" | '(?:[^'\\]|\\.)*')
  209
+            [^\s'"]*
  210
+        )+
  211
+    ) | \S+)
  212
+""", re.VERBOSE)
208 213
 
209 214
 def smart_split(text):
210 215
     r"""
2  tests/regressiontests/text/tests.py
@@ -27,6 +27,8 @@
27 27
 [u'url', u'search_page', u'words=hello']
28 28
 >>> list(smart_split(u'url search_page words="something else'))
29 29
 [u'url', u'search_page', u'words="something', u'else']
  30
+>>> list(smart_split("cut:','|cut:' '"))
  31
+[u"cut:','|cut:' '"]
30 32
 
31 33
 ### urlquote #############################################################
32 34
 >>> from django.utils.http import urlquote, urlquote_plus

0 notes on commit c8cd8b8

Please sign in to comment.
Something went wrong with that request. Please try again.