summaryrefslogtreecommitdiff
path: root/django/utils/http.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/utils/http.py')
-rw-r--r--django/utils/http.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/django/utils/http.py b/django/utils/http.py
index 15fac6bfca..f4911b4ec0 100644
--- a/django/utils/http.py
+++ b/django/utils/http.py
@@ -71,7 +71,7 @@ urlunquote_plus = allow_lazy(urlunquote_plus, six.text_type)
def urlencode(query, doseq=0):
"""
A version of Python's urllib.urlencode() function that can operate on
- unicode strings. The parameters are first case to UTF-8 encoded strings and
+ unicode strings. The parameters are first cast to UTF-8 encoded strings and
then encoded as per normal.
"""
if isinstance(query, MultiValueDict):
@@ -226,7 +226,10 @@ def same_origin(url1, url2):
Checks if two URLs are 'same-origin'
"""
p1, p2 = urllib_parse.urlparse(url1), urllib_parse.urlparse(url2)
- return (p1.scheme, p1.hostname, p1.port) == (p2.scheme, p2.hostname, p2.port)
+ try:
+ return (p1.scheme, p1.hostname, p1.port) == (p2.scheme, p2.hostname, p2.port)
+ except ValueError:
+ return False
def is_safe_url(url, host=None):
"""