From 382e5e06207010645b98f71e2d68e40c7b29eb82 Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Wed, 15 Jan 2020 10:47:22 +0200 Subject: [PATCH] Encode strings before hashing --- ckanext/googleanalytics/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ckanext/googleanalytics/views.py b/ckanext/googleanalytics/views.py index 7337c08..59b9a29 100644 --- a/ckanext/googleanalytics/views.py +++ b/ckanext/googleanalytics/views.py @@ -2,6 +2,7 @@ import hashlib import logging +import six from flask import Blueprint @@ -77,7 +78,7 @@ def _post_analytics( data_dict = { "v": 1, "tid": tk.config.get("googleanalytics.id"), - "cid": hashlib.md5(tk.c.user).hexdigest(), + "cid": hashlib.md5(six.ensure_binary(tk.c.user)).hexdigest(), # customer id should be obfuscated "t": "event", "dh": tk.request.environ["HTTP_HOST"],