Skip to content

Commit

Permalink
FIFO reading: Better compatibility with various Unicode bytes
Browse files Browse the repository at this point in the history
Some SIP headers such as "User-Agent" may contain Unicode data that
would crash the CLI on some OS/Python-3 combinations.  For example, an
"ul_dump" MI command may run into the following trace:

  File "/usr/lib/python3/dist-packages/opensipscli/communication/fifo.py", line 77, in execute
    replycmd = reply_fifo.readline()
  File "/usr/lib/python3.7/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf2 in position 2737: invalid continuation byte

This patch simply changes the default handling of byte-scanning errors,
by simply replacing unrecognized characters with a "?" symbol and moving
forward.
  • Loading branch information
liviuchircu committed Mar 2, 2022
1 parent a7a9bd2 commit 16a5673
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion opensipscli/communication/fifo.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def execute(method, params):
format(fifo_file, ex))

logger.debug("reply file '{}'".format(reply_fifo_file))
with open(reply_fifo_file, 'r') as reply_fifo:
with open(reply_fifo_file, 'r', errors='replace') as reply_fifo:
replycmd = reply_fifo.readline()
#logger.debug("received reply '{}'".format(replycmd))

Expand Down

0 comments on commit 16a5673

Please sign in to comment.