Skip to content

Commit

Permalink
[#1039] Fix for own domain
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes authored and amercader committed Nov 5, 2013
1 parent f2b8e9c commit 6282f52
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ckan/controllers/user.py
Expand Up @@ -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

0 comments on commit 6282f52

Please sign in to comment.