Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/deserialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ impl<'a> Parser<'a> {
let value = self.parse_inline_array(py, after_colon, inner_delim, inner_len)?;
list.append(value)?;
}
} else if item_str.contains(':') {
} else if self.find_key_value_colon(item_str).is_some() {
self.pos -= 1;
let value = self.parse_list_item_object(py, expected_depth)?;
list.append(value)?;
Expand Down
21 changes: 21 additions & 0 deletions tests/integration/test_complex_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,24 @@ def test_load_equals_loads(self, expected_toon):

# Verify both methods produce the same data
assert loaded_data == toon_data


class TestPrimitiveArrayColonRegression:
"""Regression tests for §9.4 expanded primitive arrays containing colons (GitHub issue)."""

def test_quoted_strings_with_colon_in_expanded_array(self):
"""Quoted strings containing a colon must be parsed as primitives, not objects (§9.3)."""
result = toons.loads('items[2|]:\n - "a:b"\n - "c:d"\n')
assert result == {"items": ["a:b", "c:d"]}

def test_single_quoted_string_with_colon_in_expanded_array(self):
"""Single quoted string with colon in expanded primitive array."""
result = toons.loads('tags[1|]:\n - "http://example.com"\n')
assert result == {"tags": ["http://example.com"]}

def test_mixed_primitives_and_colon_strings_in_expanded_array(self):
"""Expanded array mixing plain strings and quoted strings with colons."""
result = toons.loads(
'values[3|]:\n - plain\n - "key:value"\n - another\n'
)
assert result == {"values": ["plain", "key:value", "another"]}
Loading