summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2009-04-10 04:13:27 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2009-04-10 04:13:27 +0000
commitbe4a83c4483501102afbfd786100e46ed06cc05c (patch)
treee20c7f00c272e4ee29c26edadb6d91daee097725 /django
parentf6309cbf8058b77729f9ba96c26accdbb7ae5596 (diff)
Fixed #9315 -- Handle spaces in URL tag arguments.
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
Diffstat (limited to 'django')
-rw-r--r--django/template/__init__.py3
-rw-r--r--django/template/defaulttags.py2
-rw-r--r--django/utils/text.py8
3 files changed, 9 insertions, 4 deletions
diff --git a/django/template/__init__.py b/django/template/__init__.py
index 503cfb77bf..95aa36af21 100644
--- a/django/template/__init__.py
+++ b/django/template/__init__.py
@@ -480,8 +480,7 @@ filter_raw_string = r"""
'arg_sep': re.escape(FILTER_ARGUMENT_SEPARATOR),
}
-filter_raw_string = filter_raw_string.replace("\n", "").replace(" ", "")
-filter_re = re.compile(filter_raw_string, re.UNICODE)
+filter_re = re.compile(filter_raw_string, re.UNICODE|re.VERBOSE)
class FilterExpression(object):
r"""
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index a9e7f40fad..835b1a9df3 100644
--- a/django/template/defaulttags.py
+++ b/django/template/defaulttags.py
@@ -1100,7 +1100,7 @@ def url(parser, token):
The URL will look like ``/clients/client/123/``.
"""
- bits = token.contents.split(' ')
+ bits = token.split_contents()
if len(bits) < 2:
raise TemplateSyntaxError("'%s' takes at least one argument"
" (path to a view)" % bits[0])
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.