From be4a83c4483501102afbfd786100e46ed06cc05c Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Fri, 10 Apr 2009 04:13:27 +0000 Subject: Fixed #9315 -- Handle spaces in URL tag arguments. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks Natalia Bidart and Matías Bordese for most of this patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10462 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/utils/text.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'django/utils') diff --git a/django/utils/text.py b/django/utils/text.py index 8bc256e804..fe46e26b52 100644 --- a/django/utils/text.py +++ b/django/utils/text.py @@ -197,7 +197,13 @@ def javascript_quote(s, quote_double_quotes=False): return str(ustring_re.sub(fix, s)) javascript_quote = allow_lazy(javascript_quote, unicode) -smart_split_re = re.compile('("(?:[^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'(?:[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'|[^\\s]+)') +# 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) + def smart_split(text): r""" Generator that splits a string by spaces, leaving quoted phrases together. -- cgit v1.3