Skip to content

Commit 75fe130

Browse files
committed
Used a different name for the URL redirection param
Trac itself uses `referer`, so this change makes it easier to integrate with some other Trac functionalities.
1 parent 93bbd0b commit 75fe130

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

DjangoPlugin/tracdjangoplugin/plugins.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def process_request(self, req):
123123
def do_get(self, req):
124124
return "plainlogin.html", {
125125
"form": AuthenticationForm(),
126-
"next": req.args.get("next", ""),
126+
"referer": req.args.get("referer", ""),
127127
}
128128

129129
def do_post(self, req):
@@ -132,11 +132,11 @@ def do_post(self, req):
132132
req.environ["REMOTE_USER"] = form.get_user().username
133133
LoginModule(self.compmgr)._do_login(req)
134134
req.redirect(self._get_safe_redirect_url(req))
135-
return "plainlogin.html", {"form": form, "next": req.args.get("next", "")}
135+
return "plainlogin.html", {"form": form, "referer": req.args.get("referer", "")}
136136

137137
def _get_safe_redirect_url(self, req):
138138
host = urlparse(req.base_url).hostname
139-
redirect_url = iri_to_uri(req.args.get("next", ""))
139+
redirect_url = iri_to_uri(req.args.get("referer", ""))
140140

141141
if not redirect_url:
142142
redirect_url = settings.LOGIN_REDIRECT_URL

DjangoPlugin/tracdjangoplugin/tests.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_login_valid_with_custom_redirection(self):
7373
username="test",
7474
password="test",
7575
check_redirect="/test",
76-
extra_data={"next": "/test"},
76+
extra_data={"referer": "/test"},
7777
)
7878

7979
def test_login_valid_with_custom_redirection_with_hostname(self):
@@ -83,7 +83,7 @@ def test_login_valid_with_custom_redirection_with_hostname(self):
8383
username="test",
8484
password="test",
8585
check_redirect="http://localhost/test",
86-
extra_data={"next": "http://localhost/test"},
86+
extra_data={"referer": "http://localhost/test"},
8787
)
8888

8989
def test_login_valid_with_malicious_redirection(self):
@@ -108,7 +108,7 @@ def test_login_valid_with_malicious_redirection(self):
108108
username="test",
109109
password="test",
110110
check_redirect="http://localhost/test",
111-
extra_data={"next": redirect_url},
111+
extra_data={"referer": redirect_url},
112112
)
113113

114114
def assertLoginFails(self, username, password, error_message=None):

trac-env/templates/django_theme.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</form>
2929
</li>
3030
# else
31-
<li><a href="/login?next=${req.path_info|urlencode()}">Login</a></li>
31+
<li><a href="/login?referer=${req.path_info|urlencode()}">Login</a></li>
3232
# endif
3333
<li><a href="${req.href.prefs()}">Preferences</a></li>
3434
</ul>

trac-env/templates/plainlogin.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ <h2>Log in with your DjangoProject account</h2>
2525
<p>
2626
<button type="submit">Log in with DjangoProject</button>
2727
<input type="hidden" name="__FORM_TOKEN" value="${req.form_token}">{# Trac's CSRF protection #}
28-
<input type="hidden" name="next" value="${next|default('/')}">
28+
<input type="hidden" name="referer" value="${referer|default('/')}">
2929
</p>
3030
</form>
3131
</section>

0 commit comments

Comments
 (0)