ini_file: fix regression reported in #2578 (#2875) (#2887)

* Add regression test.

* Add more Unicode tests.

* Add fix.

* Add changelog.

* Work completely with Unicode.

* Update plugins/modules/files/ini_file.py

Co-authored-by: quidame <quidame@poivron.org>

Co-authored-by: quidame <quidame@poivron.org>
(cherry picked from commit 147425ef93)

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
patchback[bot] 2021-06-27 10:26:27 +02:00 committed by GitHub
parent f0b7233e8d
commit 28007079a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 73 additions and 20 deletions

View file

@ -514,3 +514,43 @@
assert:
that:
- content16 == expected16
# Regression test for https://github.com/ansible-collections/community.general/pull/2578#issuecomment-868092282
- name: Create UTF-8 test file
copy:
content: !!binary |
W2FwcDptYWluXQphdmFpbGFibGVfbGFuZ3VhZ2VzID0gZW4gZnIgZXMgZGUgcHQgamEgbHQgemhf
VFcgaWQgZGEgcHRfQlIgcnUgc2wgaXQgbmxfTkwgdWsgdGEgc2kgY3MgbmIgaHUKIyBGdWxsIGxh
bmd1YWdlIG5hbWVzIGluIG5hdGl2ZSBsYW5ndWFnZSAoY29tbWEgc2VwYXJhdGVkKQphdmFpbGFi
bGVfbGFuZ3VhZ2VzX2Z1bGwgPSBFbmdsaXNoLCBGcmFuw6dhaXMsIEVzcGHDsW9sLCBEZXV0c2No
LCBQb3J0dWd1w6pzLCDml6XmnKzoqp4sIExpZXR1dm9zLCDkuK3mlocsIEluZG9uZXNpYSwgRGFu
c2ssIFBvcnR1Z3XDqnMgKEJyYXNpbCksINCg0YPRgdGB0LrQuNC5LCBTbG92ZW7FocSNaW5hLCBJ
dGFsaWFubywgTmVkZXJsYW5kcywg0KPQutGA0LDRl9C90YHRjNC60LAsIOCupOCuruCuv+CutOCv
jSwg4LeD4LeS4LaC4LeE4La9LCDEjGVza3ksIEJva23DpWwsIE1hZ3lhcgo=
dest: '{{ output_file }}'
- name: Add entries
ini_file:
section: "{{ item.section }}"
option: "{{ item.option }}"
value: "{{ item.value }}"
path: '{{ output_file }}'
create: true
loop:
- section: app:main
option: sqlalchemy.url
value: postgresql://app:secret@database/app
- section: handler_filelog
option: args
value: (sys.stderr,)
- section: handler_filelog
option: class
value: StreamHandler
- section: handler_exc_handler
option: args
value: (sys.stderr,)
- section: båz
option: fföø
value: ḃâŗ
- section: båz
option: fföø
value: bar