summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorFlorian Apolloner <florian@apolloner.eu>2014-07-17 21:59:28 +0200
committerTim Graham <timograham@gmail.com>2014-08-20 14:39:40 -0400
commit28e765810df46a3f28ff4785491e9973593382fd (patch)
tree1f4eb55828ff9cf83a8f7d31df0c3fd1214532ed /django
parentec71191be0947e22630141e726f0e1f298f930df (diff)
Prevented reverse() from generating URLs pointing to other hosts.
This is a security fix. Disclosure following shortly.
Diffstat (limited to 'django')
-rw-r--r--django/core/urlresolvers.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
index d3bfef423b..9a399466bc 100644
--- a/django/core/urlresolvers.py
+++ b/django/core/urlresolvers.py
@@ -456,7 +456,11 @@ class RegexURLResolver(LocaleRegexProvider):
# safe characters from `pchar` definition of RFC 3986
candidate_subs = dict((k, urlquote(v, safe=RFC3986_SUBDELIMS + str('/~:@')))
for (k, v) in candidate_subs.items())
- return candidate_pat % candidate_subs
+ url = candidate_pat % candidate_subs
+ # Don't allow construction of scheme relative urls.
+ if url.startswith('//'):
+ url = '/%%2F%s' % url[2:]
+ return url
# lookup_view can be URL label, or dotted path, or callable, Any of
# these can be passed in at the top, but callables are not friendly in
# error messages.