mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-12-15 14:38:47 -05:00
MSC3873: Escape keys when flattening dicts. (#15004)
This disambiguates keys which attempt to match fields with a dot in them (e.g. m.relates_to). Disabled by default behind an experimental configuration flag.
This commit is contained in:
parent
a4126e2861
commit
c951fbedcb
4 changed files with 40 additions and 4 deletions
|
|
@ -48,6 +48,14 @@ class FlattenDictTestCase(unittest.TestCase):
|
|||
input = {"foo": {"bar": "abc"}}
|
||||
self.assertEqual({"foo.bar": "abc"}, _flatten_dict(input))
|
||||
|
||||
# If a field has a dot in it, escape it.
|
||||
input = {"m.foo": {"b\\ar": "abc"}}
|
||||
self.assertEqual({"m.foo.b\\ar": "abc"}, _flatten_dict(input))
|
||||
self.assertEqual(
|
||||
{"m\\.foo.b\\\\ar": "abc"},
|
||||
_flatten_dict(input, msc3783_escape_event_match_key=True),
|
||||
)
|
||||
|
||||
def test_non_string(self) -> None:
|
||||
"""Non-string items are dropped."""
|
||||
input: Dict[str, Any] = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue