Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.1.X] Fixed #12119. Changed smart_split to stop splitting on whites…

…pace in quotes. Backport of r12581 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12582 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 6bf75fd3f57c2074e2612d714cb73e66194dd46a 1 parent 07f2d19
@jkocherhans jkocherhans authored
Showing with 10 additions and 3 deletions.
  1. +8 −3 django/utils/text.py
  2. +2 −0  tests/regressiontests/text/tests.py
View
11 django/utils/text.py
@@ -200,9 +200,14 @@ def fix(match):
# Expression to match some_token and some_token="with spaces" (and similarly
# for single-quoted strings).
smart_split_re = re.compile(r"""
- ([^\s"]*"(?:[^"\\]*(?:\\.[^"\\]*)*)"\S*|
- [^\s']*'(?:[^'\\]*(?:\\.[^'\\]*)*)'\S*|
- \S+)""", re.VERBOSE)
+ ((?:
+ [^\s'"]*
+ (?:
+ (?:"(?:[^"\\]|\\.)*" | '(?:[^'\\]|\\.)*')
+ [^\s'"]*
+ )+
+ ) | \S+)
+""", re.VERBOSE)
def smart_split(text):
r"""
View
2  tests/regressiontests/text/tests.py
@@ -27,6 +27,8 @@
[u'url', u'search_page', u'words=hello']
>>> list(smart_split(u'url search_page words="something else'))
[u'url', u'search_page', u'words="something', u'else']
+>>> list(smart_split("cut:','|cut:' '"))
+[u"cut:','|cut:' '"]
### urlquote #############################################################
>>> from django.utils.http import urlquote, urlquote_plus

0 comments on commit 6bf75fd

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