File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 8
8
9
9
class TestValidators (TestCase ):
10
10
def test_validate_good_uris (self ):
11
- good_urls = 'http://example.com/ http://example.it/?key=val'
11
+ good_urls = 'http://example.com/ http://example.it/?key=val http://example '
12
12
# Check ValidationError not thrown
13
13
validate_uris (good_urls )
14
14
15
15
def test_validate_bad_uris (self ):
16
- bad_urls = 'http://example.com http://example'
17
- self .assertRaises (ValidationError , validate_uris , bad_urls )
16
+ bad_url = 'http://example.com/#fragment'
17
+ self .assertRaises (ValidationError , validate_uris , bad_url )
18
+ bad_url = 'http:/example.com'
19
+ self .assertRaises (ValidationError , validate_uris , bad_url )
Original file line number Diff line number Diff line change @@ -40,10 +40,17 @@ def __call__(self, value):
40
40
url = value
41
41
42
42
43
+ class RedirectURIValidator (URIValidator ):
44
+ def __call__ (self , value ):
45
+ super (RedirectURIValidator , self ).__call__ (value )
46
+ if len (value .split ('#' )) > 1 :
47
+ raise ValidationError ('Redirect URIs must not contain fragments' )
48
+
49
+
43
50
def validate_uris (value ):
44
51
"""
45
52
This validator ensures that `value` contains valid blank-separated urls"
46
53
"""
47
- v = URIValidator ()
54
+ v = RedirectURIValidator ()
48
55
for uri in value .split ():
49
56
v (uri )
You can’t perform that action at this time.
0 commit comments