Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2991,7 +2991,8 @@
file.filename = utils.secure_filename(file.filename)
file_location = commons_file_helper.ensureTrailingSlash(
app.config['FILE_UPLOAD_TEMP_DIR']) + temp_id + os.sep + file.filename
with open(file_location, newline='') as tsvfile:
tsvfile = open_tsv(file_location)
with tsvfile:
reader = csv.DictReader(tsvfile, delimiter='\t')
first = True
for row in reader:
Expand Down Expand Up @@ -3047,7 +3048,8 @@
tsvfile_name = tsv_directory + temp_file_name
records = []
headers = []
with open(tsvfile_name, newline='') as tsvfile:
tsvfile = open_tsv(tsvfile_name)
with tsvfile:
reader = csv.DictReader(tsvfile, delimiter='\t')
first = True
for row in reader:
Expand Down Expand Up @@ -3114,6 +3116,15 @@
return Response(json.dumps(response, sort_keys=True), status_code, mimetype='application/json')


def open_tsv(path):
try:
f = open(path, newline='', encoding='utf-8-sig')

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1).
Comment thread
yuanzhou marked this conversation as resolved.
Dismissed
f.read()
f.seek(0)
except UnicodeDecodeError:
return open(path, newline='', encoding='utf-16')

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1).
Comment thread
yuanzhou marked this conversation as resolved.
Dismissed


def validate_samples(headers, records, header):
error_msg = []
file_is_valid = True
Expand Down
Loading