balena-io-modules / drivelist

List all connected drives in your computer, in all major operating systems
Apache License 2.0
239 stars 90 forks source link

Fix lsblk --pairs parsing when a value has hexadecimal escapes #362

Closed zvin closed 4 years ago

zvin commented 4 years ago

Change-type: patch

lurch commented 4 years ago

Seems that this is related to #320 ?

In python3 :

>>> b'\xe2\x88\x95dev\xe2\x88\x95sdi'.decode('utf8')
'∕dev∕sdi'

Although note that the slashes in that output string are not "regular" slashes but some weird variant...

>>> b'\xe2\x88\x95dev\xe2\x88\x95sdi'.decode('utf8').encode('utf8')
b'\xe2\x88\x95dev\xe2\x88\x95sdi'
>>> '/dev/sdi'.encode('utf8')
b'/dev/sdi'

EDIT: Ahhh, it's a "division slash" https://www.fileformat.info/info/unicode/char/2215/index.htm

>>> b'\xe2\x88\x95dev\xe2\x88\x95sdi'.decode('utf8') == '\u2215dev\u2215sdi'
True