handle byte order marks properly when guessing file types

pull/49/head
Hartmut Holzgraefe 2020-05-21 09:30:14 +00:00
rodzic 8a8119e778
commit 2dc1014f45
1 zmienionych plików z 2 dodań i 3 usunięć

Wyświetl plik

@ -127,10 +127,9 @@ def donate_thanks(request):
return render_to_response('maposmatic/donate-thanks.html')
def create_upload_file(job, file):
first_line = file.readline()
f = file.open()
first_line = file.readline().decode("utf-8-sig")
LOG.info("firstline type %s" % type(first_line))
if first_line.startswith(b'<?xml'):
if first_line.startswith(u'<?xml'):
file_type = 'gpx'
else:
file_type = 'umap'