Update utils.py

Fixed infinitive loop while parsing Array of strings fields.ArrayField(fields.StringField())

If your string has a single quote(stored as escaped \'), repeated unescape will remove \, making it impossible to decode field using the following parse_array.

Note, decode function unescapes the bytes the first time.
This commit is contained in:
romamo 2022-11-30 20:06:49 +02:00 committed by GitHub
parent 45a9200ff6
commit 33ab225168
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,8 +81,9 @@ def parse_tsv(line):
line = line.decode()
if line and line[-1] == '\n':
line = line[:-1]
return [unescape(value) for value in line.split(str('\t'))]
# Repetitive unescape using undocumented function
# return [unescape(value) for value in line.split(str('\t'))]
return line.split(str('\t'))
def parse_array(array_string):
"""