fix: keep `key=` distinct from a valueless `key` in TXT records by bboe · Pull Request #1813 · python-zeroconf/python-zeroconf · GitHub
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
9 changes: 8 additions & 1 deletion src/zeroconf/_services/info.pxd
8 changes: 5 additions & 3 deletions src/zeroconf/_services/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,12 @@ def _unpack_text_into_properties(self) -> None:
length = text[index]
index += 1
key_value = text[index : index + length]
key_sep_value = key_value.partition(b"=")
key = key_sep_value[0]
key, sep, value = key_value.partition(b"=")
if key not in properties:
properties[key] = key_sep_value[2] or None
# RFC 6763 section 6.4 distinguishes a key with no '=' (a
# boolean attribute: present, no value) from `key=` (present
# with an empty value), so test the separator, not the value.
properties[key] = value if sep else None
index += length

self._properties = properties
Expand Down
58 changes: 58 additions & 0 deletions tests/services/test_info.py
Loading