mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
Fix for to_text and to_bytes error handlers
* surrogate_then_strict doesn't exist. Switch to surrogate_or_strict
instead.
* Found some bugs in the _text.py implementation
* The composed error handlers (error handlers which are made up of two
or more python encoding error handlers) had a wrong string in it,
'surrogate_or_escape' doesn't exist. Replaced that with
'surrogate_or_replace' which is the correct handler name.
* Left comment about the implicit conditions that are part of the
surrogate_then_replace code path
Fixes #23865
Fixes #23861
This commit is contained in:
@@ -262,7 +262,7 @@ def get_hash(data, hashtype='sha1'):
|
||||
except:
|
||||
return None
|
||||
|
||||
h.update(to_bytes(data, errors='surrogate_then_strict'))
|
||||
h.update(to_bytes(data, errors='surrogate_or_strict'))
|
||||
return h.hexdigest()
|
||||
|
||||
|
||||
@@ -453,11 +453,11 @@ def do_groupby(environment, value, attribute):
|
||||
|
||||
|
||||
def b64encode(string):
|
||||
return to_text(base64.b64encode(to_bytes(string, errors='surrogate_then_strict')))
|
||||
return to_text(base64.b64encode(to_bytes(string, errors='surrogate_or_strict')))
|
||||
|
||||
|
||||
def b64decode(string):
|
||||
return to_text(base64.b64decode(to_bytes(string, errors='surrogate_then_strict')))
|
||||
return to_text(base64.b64decode(to_bytes(string, errors='surrogate_or_strict')))
|
||||
|
||||
|
||||
class FilterModule(object):
|
||||
|
||||
Reference in New Issue
Block a user