Skip to content

Ghidra is a software reverse engineering (SRE) framework

PyGhidra: reorder valid_fields guard for readability, add comment

unslept177ce9f04338
diff --git a/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/version.py b/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/version.py
index 4c013a57e2..3c1202185e 100644
--- a/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/version.py
+++ b/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/version.py
@@ -77,10 +77,14 @@ class ExtensionDetails:
def cast(key, value):
return cls.__annotations__[key](value)
lines = ext_path.read_text().splitlines()
+ # `sep` is empty for a line with no '=' at all (e.g. a stray bare "id"
+ # line). Without checking it, such a line would be silently accepted
+ # as a valid field with an empty value if the line happened to match
+ # a field name exactly.
kwargs = {
key: cast(key, value)
for key, sep, value in map(lambda l: l.partition("="), lines)
- if sep and key in valid_fields
+ if key in valid_fields and sep
}
return cls(**kwargs)