FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

chore: restructure the txt parse loop and reword the remaining echoes from the twelfth audit by bdraco · Pull Request #1897 · python-zeroconf/python-zeroconf · GitHub

Repository navigation

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

Filter by extension

Filter by extension .pxd  (1) .py  (3) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion src/zeroconf/_cache.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def async_add_records(self, entries: Iterable[DNSRecord]) -> bool:
return new

def async_all_by_details(self, name: _str, type_: _int, class_: _int) -> list[DNSRecord]:
"""Gets all matching entries by details.
"""Return every cached record carrying this name, type and class.

This function is not thread-safe and must be called from
the event loop.
Expand Down
5 changes: 3 additions & 2 deletions src/zeroconf/_handlers/query_handler.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ def async_response( # pylint: disable=unused-argument
continue
if ucast_source:
query_res.add_ucast_question_response(answer_set)
# We always multicast as well even if its a unicast
# source as long as we haven't done it recently (75% of ttl)
# The answer also goes out by multicast even for a unicast
# source; a copy multicast within the last second is folded
# into the aggregated response instead (RFC 6762 section 14)
query_res.add_mcast_question_response(answer_set)

return query_res.answers()
Expand Down
4 changes: 3 additions & 1 deletion src/zeroconf/_services/info.pxd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ cdef class ServiceInfo(RecordUpdateListener):

@cython.locals(
length="unsigned char",
index="unsigned int",
pos="unsigned int",
start="unsigned int",
total="unsigned int",
key_value=bytes,
key=bytes,
sep=bytes,
Expand Down
16 changes: 8 additions & 8 deletions src/zeroconf/_services/info.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1044,26 +1044,26 @@ def _set_text(self, text: bytes) -> None:
def _unpack_text_into_properties(self) -> None:
"""Unpacks the text field into properties"""
text = self.text
end = len(text)
if end == 0:
total = len(text)
if total == 0:
# Properties should be set atomically
# in case another thread is reading them
self._properties = {}
return

index = 0
properties: dict[bytes, bytes | None] = {}
while index < end:
length = text[index]
index += 1
key_value = text[index : index + length]
pos = 0
while pos < total:
length = text[pos]
start = pos + 1
key_value = text[start : start + length]
pos = start + length
key, sep, value = key_value.partition(b"=")
if key not in properties:
# 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
Loading

Back | FazBrowse Home | New Git URL