Commits

Josh VanderLinden committed f92e801

Trying to handle unicode in user agents and referrers a bit better... Probably breaks link-backs, but should keep things operational at least. GC #17

Comments (0)

Files changed (2)

tracking/middleware.py

 
         # create some useful variables
         ip_address = utils.get_ip(request)
-        user_agent = request.META.get('HTTP_USER_AGENT', '')[:255]
+        user_agent = utils.u_clean(request.META.get('HTTP_USER_AGENT', '')[:255])
 
         # see if the user agent is not supposed to be tracked
         for ua in UntrackedUserAgent.objects.all():
         # at least an hour, update their referrer URL
         one_hour_ago = now - timedelta(hours=1)
         if not visitor.last_update or visitor.last_update <= one_hour_ago:
-            visitor.referrer = request.META.get('HTTP_REFERER', 'unknown')[:255]
+            visitor.referrer = utils.u_clean(request.META.get('HTTP_REFERER', 'unknown')[:255])
 
             # reset the number of pages they've been to
             visitor.page_views = 0

tracking/utils.py

     """
     return getattr(settings, 'TRACKING_CLEANUP_TIMEOUT', 24)
 
-def get_untracked_prefixes():
-    """Gets a list of prefixes that shouldn't be tracked"""
-
-    return getattr(settings, 'NO_TRACKING_PREFIXES', [])
-
 def u_clean(s):
     """A strange attempt at cleaning up unicode"""