| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Trac
Revision: 7493
Author: rblank
Date: 21 Aug 2008 15:44:31
Diff at Trac: http://trac.edgewall.org/changeset/7493
Changes:0.11-stable: Added an optional `referer=` argument to `/login` to specify the URL to redirect to instead of using the `Referer:` HTTP header.
This is the non-controversial part of the patch to solve #5340. The code was mostly copied from th:AccountManagerPlugin, which already implements this functionality.
This also fixes a small typo in `trac/web/href.py`.
Files:| ... | ...@@ -181,6 +181,9 @@ | |
| 181 | 181 | doc='The HTTP method of the request') |
| 182 | 182 | path_info = property(fget=lambda self: self.environ.get('PATH_INFO', '').decode('utf-8'), |
| 183 | 183 | doc='Path inside the application') |
| 184 | query_string = property(fget=lambda self: self.environ.get('QUERY_STRING', | |
| 185 | ''), | |
| 186 | doc='Query part of the request') | |
| 184 | 187 | remote_addr = property(fget=lambda self: self.environ.get('REMOTE_ADDR'), |
| 185 | 188 | doc='IP address of the remote user') |
| 186 | 189 | remote_user = property(fget=lambda self: self.environ.get('REMOTE_USER'), |
| ... | ...@@ -197,13 +197,16 @@ | |
| 197 | 197 | |
| 198 | 198 | def _redirect_back(self, req): |
| 199 | 199 | """Redirect the user back to the URL she came from.""" |
| 200 | referer = req.get_header('Referer') | |
| 200 | referer = self._referer(req) | |
| 201 | 201 | if referer and not (referer == req.base_url or \ |
| 202 | 202 | referer.startswith(req.base_url.rstrip('/')+'/')): |
| 203 | 203 | # only redirect to referer if it is from the same site |
| 204 | 204 | referer = None |
| 205 | 205 | req.redirect(referer or req.abs_href()) |
| 206 | 206 | |
| 207 | def _referer(self, req): | |
| 208 | return req.args.get('referer') or req.get_header('Referer') | |
| 209 | ||
| 207 | 210 | |
| 208 | 211 | class HTTPAuthentication(object): |
| 209 | 212 |
| ... | ...@@ -129,7 +129,7 @@ | |
| 129 | 129 | if type(value) in (list, tuple): |
| 130 | 130 | for i in [i for i in value if i != None]: |
| 131 | 131 | params.append((name, i)) |
| 132 | elif v != None: | |
| 132 | elif value != None: | |
| 133 | 133 | params.append((name, value)) |
| 134 | 134 | |
| 135 | 135 | if args: |