Repository navigation
fix: robustness against malformed SIP headers, deep JSON and broken files - #244
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
json.loads raises RecursionError, not a ValueError, on a text such as "[" * 100000: it left _handle_text, the socket loop caught it and dropped the client. It is now ignored like any other invalid JSON. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
json.loads raises RecursionError, not ValueError, on input such as "[" * 100000. _parse_actuators let it escape, so the options step failed with a generic error instead of showing actuators_bad_json. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"sip:[fe80::1]:5060" gave "[fe80::1]:5060", which never matches the sender address a socket reports. Today the local UDP socket is IPv4 only, so nothing changes for current plants. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Windows UNC path became file://server/share/..., where SQLite reads the server as the URI authority and refuses it. An empty authority in front (file:////server/share/...) keeps the whole path. Same fix in the importer and in tools/parse_rubrica.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
{"action": [...]} made `action in ADMIN_WS_ACTIONS` (a set) raise TypeError
outside the action's try: the socket loop caught it and dropped the client,
the same failure as JSON that is not an object (fixed above).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
json.load raises RecursionError, not ValueError, on "[[[[...": the docstring promises that a broken file stops nothing. Same case as the REST client and the options flow above. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…code "[]", "5" or a bare string made json.load(f)["pincode"] raise TypeError, and deep nesting RecursionError: neither was caught, so the code file did not fall back to a new code like any other broken file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RFC 3261 7.3.3: a UA must accept the short form of a header name. A message with v:/i:/m: was parsed with no Via, Call-ID or Contact, so the reply carried an empty Via and _dialog_hosts missed the Via host. _split_stream already accepted l: for Content-Length. Vimar plants have only been seen sending the long form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Small robustness fixes for malformed or unusual input, each with a test that fails without it. None changes behaviour with the messages and files real plants produce today; they stop a bad input from crashing a handler, dropping a client or logging errors in a loop.
_host_ofno longer raisesIndexErroron an emptyVia(it made_dialog_hostsfail on every packet from a host other than the proxy, each with an ERROR log and a 2 s pause); it returns the bare address of an IPv6 reference (sip:[fe80::1]:5060);_parsereads the compact header names of RFC 3261 7.3.3 (v,f,t,i,m,l...)./audio_ws: valid JSON that is not an object, JSON nested too deep and anactionthat is not a string are ignored like invalid JSON, instead of dropping the client."[" * 100000, wherejson.loadsraisesRecursionError, notValueError): aRestErrorin the REST client,actuators_bad_jsonin the options flow, an empty ring log.rubrica.dbon a Windows UNC path opens (file:////server/share/...), in the importer and intools/parse_rubrica.py.Tested on
Tests only:
python -m pytest tests -m "not live and not media and not browser and not docker"(2531 passed, 32 skipped) andruff check .clean, on Windows.Docs
Docs: not needed (no user-facing change for valid input).
Changelog
Changelog: Bug fixes - A malformed message from the network or a broken file no longer drops the card's audio connection or stops the SIP reader
Changelog: Bug fixes - The phonebook import opens a rubrica.db on a network share (UNC path)
Changelog: Other changes - Robustness fixes for malformed SIP headers, JSON nested too deep and broken HomeKit setup-code files, with tests
🤖 Generated with Claude Code