2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-28 11:57:34 +00:00

Merge "Workaround likely spec deviations and fix parsing"

This commit is contained in:
Jenkins 2015-10-23 20:11:59 +00:00 committed by Gerrit Code Review
commit f9702d902f

View File

@ -214,9 +214,16 @@ class FRU(object):
# return it as a bytearray, not much to be done for it
return retinfo, newoffset
elif currtype == 3: # text string
if lang == 0:
# Sometimes BMCs have FRU data with 0xff termination
# contrary to spec, but can be tolerated
# also in case something null terminates, handle that too
# strictly speaking, \xff should be a y with diaeresis, but
# erring on the side of that not being very relevant in practice
# to fru info, particularly the last values
retinfo = retinfo.rstrip('\xff\x00 ')
if lang in (0, 25):
try:
retinfo = retinfo.decode('utf-8')
retinfo = retinfo.decode('iso-8859-1')
except UnicodeDecodeError:
pass
else: