From 6282f52dbc214bcc7c4cbe3a73d7e0d1773d5649 Mon Sep 17 00:00:00 2001 From: tobes Date: Wed, 26 Jun 2013 14:32:44 +0100 Subject: [PATCH] [#1039] Fix for own domain --- ckan/controllers/user.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ckan/controllers/user.py b/ckan/controllers/user.py index 358bdfa8257..f42ee21359c 100644 --- a/ckan/controllers/user.py +++ b/ckan/controllers/user.py @@ -610,8 +610,11 @@ def unfollow(self, id): def _sane_came_from(self, url): '''Returns True if came_from is local''' - return not bool(not url - # url has a scheme eg http:// - or urlparse(url).scheme - # url starts with // which can be none relative - or (len(url) >= 2 and url.startswith('//'))) + if not url or (len(url) >= 2 and url.startswith('//')): + return False + parsed = urlparse(url) + if parsed.scheme: + domain = urlparse(h.url_for('/', qualified=True)).netloc + if domain != parsed.netloc: + return False + return True