File tree Expand file tree Collapse file tree 1 file changed +21
-7
lines changed
DjangoPlugin/tracdjangoplugin Expand file tree Collapse file tree 1 file changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -85,13 +85,27 @@ def test_login_valid_with_custom_redirection_with_hostname(self):
85
85
def test_login_valid_with_malicious_redirection (self ):
86
86
self .env .config .set ("trac" , "base_url" , "http://localhost" )
87
87
User .objects .create_user (username = "test" , password = "test" )
88
- with self .settings (LOGIN_REDIRECT_URL = "/test" ):
89
- self .assertLoginSucceeds (
90
- username = "test" ,
91
- password = "test" ,
92
- check_redirect = "http://localhost/test" ,
93
- extra_data = {"next" : "http://example.com/evil" },
94
- )
88
+
89
+ # adapted from django/tests/auth_tests/test_views.py
90
+ for redirect_url in [
91
+ "http://example.com" ,
92
+ "http://example.com/evil" ,
93
+ "http:///example.com" ,
94
+ "https://example.com" ,
95
+ "ftp://example.com" ,
96
+ "///example.com" ,
97
+ "//example.com" ,
98
+ 'javascript:alert("XSS")' ,
99
+ ]:
100
+ with self .subTest (url = redirect_url ), self .settings (
101
+ LOGIN_REDIRECT_URL = "/test"
102
+ ):
103
+ self .assertLoginSucceeds (
104
+ username = "test" ,
105
+ password = "test" ,
106
+ check_redirect = "http://localhost/test" ,
107
+ extra_data = {"next" : redirect_url },
108
+ )
95
109
96
110
def assertLoginFails (self , username , password , error_message = None ):
97
111
if error_message is None :
You can’t perform that action at this time.
0 commit comments