utilities.py: Ensure null terminators are stripped when value is already string

This commit is contained in:
Dhinak G
2022-05-29 13:23:49 -04:00
committed by GitHub
parent e8f2f7fd78
commit 391b5381f6

View File

@@ -345,8 +345,11 @@ def get_nvram(variable: str, uuid: str = None, *, decode: bool = False):
value = ioreg.corefoundation_to_native(value)
if decode and isinstance(value, bytes):
value = value.strip(b"\0").decode()
if decode:
if isinstance(value, bytes):
value = value.strip(b"\0").decode()
elif isinstance(value, str):
value = value.strip("\0")
return value