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

Fixes #1859: Implemented support for line breaks within CSV fields

This commit is contained in:
Jeremy Stretch
2018-02-02 13:32:16 -05:00
parent 59dcbce417
commit 60c03a646c
4 changed files with 64 additions and 69 deletions

View File

@@ -1,7 +1,7 @@
from __future__ import unicode_literals
import csv
import itertools
from io import StringIO
import re
from django import forms
@@ -245,14 +245,10 @@ class CSVDataField(forms.CharField):
def to_python(self, value):
# Python 2's csv module has problems with Unicode
if not isinstance(value, str):
value = value.encode('utf-8')
records = []
reader = csv.reader(value.splitlines())
reader = csv.reader(StringIO(value))
# Consume and valdiate the first line of CSV data as column headers
# Consume and validate the first line of CSV data as column headers
headers = next(reader)
for f in self.required_fields:
if f not in headers: