Merge "Use utf-16-le if BOM not present"
This commit is contained in:
commit
cf46443120
@ -297,8 +297,14 @@ def _run_efibootmgr(valid_efi_bootloaders, device, efi_partition,
|
|||||||
'File: %s', v_bl)
|
'File: %s', v_bl)
|
||||||
# These files are always UTF-16 encoded, sometimes have a header.
|
# These files are always UTF-16 encoded, sometimes have a header.
|
||||||
# Positive bonus is python silently drops the FEFF header.
|
# Positive bonus is python silently drops the FEFF header.
|
||||||
with open(mount_point + '/' + v_bl, 'r', encoding='utf-16') as csv:
|
try:
|
||||||
contents = str(csv.read())
|
with open(mount_point + '/' + v_bl, 'r',
|
||||||
|
encoding='utf-16') as csv:
|
||||||
|
contents = str(csv.read())
|
||||||
|
except UnicodeError:
|
||||||
|
with open(mount_point + '/' + v_bl, 'r',
|
||||||
|
encoding='utf-16-le') as csv:
|
||||||
|
contents = str(csv.read())
|
||||||
csv_contents = contents.split(',', maxsplit=3)
|
csv_contents = contents.split(',', maxsplit=3)
|
||||||
csv_filename = v_bl.split('/')[-1]
|
csv_filename = v_bl.split('/')[-1]
|
||||||
v_efi_bl_path = v_bl.replace(csv_filename, str(csv_contents[0]))
|
v_efi_bl_path = v_bl.replace(csv_filename, str(csv_contents[0]))
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
In case the CSV file used for the bootloader hint does not have BOM
|
||||||
|
we fail reading its content as utf-16 codec is too generic.
|
||||||
|
Fail over to utf-16-le as Little Endian is mostly used.
|
Loading…
x
Reference in New Issue
Block a user