mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Fix hash filter for non-ascii strings and Python3
hashlib hashes operate on byte strings. When given a text string on Python3, hashlib backtraces. When given a text string on Python2, hashlib will backtrace if the string contains non-ascii characters. Encode the text string to utf-8 prior to hashing to avoid this problem. Fixes #21452
This commit is contained in:
parent
e89259dbd0
commit
99fd2328af
2 changed files with 8 additions and 2 deletions
|
@ -119,3 +119,9 @@
|
|||
assert:
|
||||
that:
|
||||
- "users | json_query('[*].hosts[].host') == ['host_a', 'host_b', 'host_c', 'host_d']"
|
||||
|
||||
- name: Test hash filter
|
||||
assert:
|
||||
that:
|
||||
- '"{{ "hash" | hash("sha1") }}" == "2346ad27d7568ba9896f1b7da6b5991251debdf2"'
|
||||
- '"{{ "café" | hash("sha1") }}" == "f424452a9673918c6f09b0cdd35b20be8e6ae7d7"'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue