From 16ac6abd0a5e41ac35e8f51980091c3751579248 Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Wed, 10 May 2017 11:57:28 -0500 Subject: [PATCH] 0.7: Parse the referrer header instead of assuming the request.get_host is going to be in the referrer --- broadcasts/__init__.py | 4 ++-- broadcasts/views.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/broadcasts/__init__.py b/broadcasts/__init__.py index d94a1a0..4c22267 100644 --- a/broadcasts/__init__.py +++ b/broadcasts/__init__.py @@ -5,8 +5,8 @@ """ __version_info__ = { 'major': 0, - 'minor': 6, - 'micro': 4, + 'minor': 7, + 'micro': 0, 'releaselevel': 'final', 'serial': 1 } diff --git a/broadcasts/views.py b/broadcasts/views.py index 792dfa1..1bc7a18 100644 --- a/broadcasts/views.py +++ b/broadcasts/views.py @@ -46,6 +46,7 @@ def get_messages(request): """ Get messages for the user """ + import urlparse if request.user.is_authenticated(): msgs = BroadcastMessage.objects.current().for_auth_users() else: @@ -58,9 +59,8 @@ def get_messages(request): msgs = msgs.exclude(pk__in=list(excluded)) # filter them by the HTTP_REFERER - host = "https://" if request.is_secure() else "http://" - host += request.get_host() - path = request.META.get('HTTP_REFERER', '/').replace(host, "") + url_parts = urlparse.urlparse(request.META.get('HTTP_REFERER', '/')) + path = url_parts.path valid_messages = [msg for msg in msgs if re.match(msg.url_target, path)] msg_list = [] for msg in valid_messages: