summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJack Cushman <jcushman@law.harvard.edu>2019-12-21 13:22:18 -0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-01-09 14:41:41 +0100
commiteb629f4c028ae220084904db84d633d7b3f0af20 (patch)
treed1c16b7756a6aebc89dec4dc5236e00d1e469524 /django
parentceecd0556dc6f013b5b62fedb12453b8ae3b8067 (diff)
Fixed #30995 -- Allowed converter.to_url() to raise ValueError to indicate no match.
Diffstat (limited to 'django')
-rw-r--r--django/urls/resolvers.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py
index 120e0396af..6e3f2443c9 100644
--- a/django/urls/resolvers.py
+++ b/django/urls/resolvers.py
@@ -632,11 +632,18 @@ class URLResolver:
candidate_subs = kwargs
# Convert the candidate subs to text using Converter.to_url().
text_candidate_subs = {}
+ match = True
for k, v in candidate_subs.items():
if k in converters:
- text_candidate_subs[k] = converters[k].to_url(v)
+ try:
+ text_candidate_subs[k] = converters[k].to_url(v)
+ except ValueError:
+ match = False
+ break
else:
text_candidate_subs[k] = str(v)
+ if not match:
+ continue
# WSGI provides decoded URLs, without %xx escapes, and the URL
# resolver operates on such URLs. First substitute arguments
# without quoting to build a decoded URL and look for a match.