mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-30 23:33:09 +00:00
[PR #6662/bb216934 backport][stable-7] csv module utils: detect unicode BOM in content (#6695)
csv module utils: detect unicode BOM in content (#6662)
* csv module utils: detect unicode BOM in content
* fix handling of py2
* fix comment
* add changelog frag
* add missing link
* simplification
(cherry picked from commit bb2169340d)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
@@ -55,8 +55,10 @@ def initialize_dialect(dialect, **kwargs):
|
||||
|
||||
|
||||
def read_csv(data, dialect, fieldnames=None):
|
||||
|
||||
BOM = to_native(u'\ufeff')
|
||||
data = to_native(data, errors='surrogate_or_strict')
|
||||
if data.startswith(BOM):
|
||||
data = data[len(BOM):]
|
||||
|
||||
if PY3:
|
||||
fake_fh = StringIO(data)
|
||||
|
||||
Reference in New Issue
Block a user