Fix RNA path resolving failing to lookup empty string properties

An empty string is a valid ID property name, when set, RNA's
internal lookup function (rna_path_token_in_brackets), considered
the path invalid.

Now quoted tokens are allowed to be empty.

This fixes Python exceptions being thrown in the custom property editor
with empty custom property names.
This commit is contained in:
Campbell Barton 2023-08-22 13:31:26 +10:00
parent e044c5f12b
commit 8df5205028
2 changed files with 8 additions and 3 deletions

View File

@ -125,9 +125,12 @@ static char *rna_path_token_in_brackets(const char **path,
return nullptr;
}
/* Empty, return. */
if (UNLIKELY(len == 0)) {
return nullptr;
/* Support empty strings in quotes, as this is a valid key for an ID-property. */
if (!quoted) {
/* Empty, return. */
if (UNLIKELY(len == 0)) {
return nullptr;
}
}
/* Try to use fixed buffer if possible. */

View File

@ -281,6 +281,8 @@ class TestRNAData(TestHelper, unittest.TestCase):
'[""]',
'["""]',
'[""""]',
# Empty properties are also valid.
"",
)
for key_id in keys_to_test:
self.id[key_id] = 1