Repository navigation
fix: decode escaped unix domain socket output URI paths - #101
Open
reginaldalfret wants to merge 1 commit into
Open
reginaldalfret wants to merge 1 commit into
reginaldalfret wants to merge 1 commit into
Conversation
Signed-off-by: reginaldalfret <reginaldalfret@gmail.com>
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.
Summary
Decode the path component of a
unix://output URI before connecting or sending to it. For example, a configured unix domain socket path containing escaped spaces (%20) or other percent-encoded characters currently attempts to reach a socket file with the literal escape sequence rather than connecting to the intended path containing spaces.This mirrors the decoding behavior implemented for
file://output URIs in #97.Root cause
SocketWriter._init_unixwas directly assigningurlparse(location).pathtoself._addresswithout callingunquote(). When a URI such asunix:///run/spectatord/my%20service/spectatord.unixis provided,urlparse().pathpreserves the percent-encoded sequences, causing socket communication to target the wrong filesystem path. Additionally,self._familywas referencingsocket.AF_UNIXdirectly at initialization rather than usinggetattr(socket, "AF_UNIX", ...), causingAttributeErroron environments lacking AF_UNIX.Changes
spectator/writer/socket_writer.py:unquote(urlparse(location).path)in_init_unix.self._familyviagetattr(socket, "AF_UNIX", socket.AF_INET)and added a defensive guard in_acquire_socketif AF_UNIX is unsupported on the host platform.tests/writer/test_socket_writer_unix.py:test_socket_writer_unix_escaped_addressverifying that escaped URI paths like%20are correctly decoded.test_socket_writer_unix_escaped_pathverifying end-to-end datagram delivery over a path containing spaces.@unittest.skipUnless(hasattr(socket, "AF_UNIX"), ...)to prevent socket server test crashes on platforms lacking AF_UNIX.Verification
pytest tests/writer/test_socket_writer_unix.pypassed cleanly.mypy --platform linux spectator testspassed across all 59 source files with 0 errors.pylint --rcfile=.pylintrc-relaxedrated both changed files 10.00/10.