1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #4222: Escape double quotes on encapsulated values during CSV export

This commit is contained in:
Jeremy Stretch
2020-02-24 13:29:00 -05:00
parent 36f8d6d259
commit 76138f3080
2 changed files with 3 additions and 1 deletions

View File

@@ -31,8 +31,9 @@ def csv_format(data):
if not isinstance(value, str):
value = '{}'.format(value)
# Double-quote the value if it contains a comma
# Double-quote the value if it contains a comma or line break
if ',' in value or '\n' in value:
value = value.replace('"', '""') # Escape double-quotes
csv.append('"{}"'.format(value))
else:
csv.append('{}'.format(value))