diff options
Diffstat (limited to 'src/mailman/rest/helpers.py')
| -rw-r--r-- | src/mailman/rest/helpers.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mailman/rest/helpers.py b/src/mailman/rest/helpers.py index 0bc312b1f..2b79a0e8a 100644 --- a/src/mailman/rest/helpers.py +++ b/src/mailman/rest/helpers.py @@ -59,7 +59,7 @@ def path_to(resource): :return: The full path to the resource. :rtype: bytes """ - return b'{0}://{1}:{2}/{3}/{4}'.format( + return '{0}://{1}:{2}/{3}/{4}'.format( ('https' if as_boolean(config.webservice.use_https) else 'http'), config.webservice.hostname, config.webservice.port, @@ -107,8 +107,10 @@ def etag(resource): assert 'http_etag' not in resource, 'Resource already etagged' # Calculate the tag from a predictable (i.e. sorted) representation of the # dictionary. The actual details aren't so important. pformat() is - # guaranteed to sort the keys. - etag = hashlib.sha1(pformat(resource)).hexdigest() + # guaranteed to sort the keys, however it returns a str and the hash + # library requires a bytes. Use the safest possible encoding. + hashfood = pformat(resource).encode('raw-unicode-escape') + etag = hashlib.sha1(hashfood).hexdigest() resource['http_etag'] = '"{0}"'.format(etag) return json.dumps(resource, cls=ExtendedEncoder) |
