-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve RCON message body decoding #14
Comments
These changes will more or less be incorporated into a rewrite of the RCON module. |
My server is running on Linux, the player name in response may contains non-ascii char. And I just checked other libraries, all of that used
|
Any update on this one? I tried changing
Quite unhelpful. I'm not sure why I've tried pretty much everything mentioned in the docs. I can't run |
I've hit this issue yesterday. I have my own web interface for the server I'm running, which is dependent on this package. It was stable as hell until someone joined a server with a weird chars in his name. That's when simpe
After looking into detalis a bit further it does not matter what encoding you are using - you might hit this issue in any case. IMO, quick (right?) solution would be to simply drop those chars that can't be encoded:
I'll create a PR, and then it's up to you to decide what would be the correct way to do this. |
Here you go. Feel free to update a commit message if needed. |
For others who may find this in the future, this is what I found a solution in: First, read https://python-valve.readthedocs.io/en/latest/rcon.html#unicode-and-string-encoding
This works for me on a Ubuntu 18 LTS server running this under Python 3.6 against SRCDS running on the same instance. |
#13 highlighted a case where the body of an RCON message (a response to a
status
command to be specific) may not be valid ASCII.This is contrary to the Valve wiki page for RCON which seems to imply that RCON message bodies should be null terminated ASCII encoded strings. Evidently this isn't always the case. As I was unable to recreate the issue for my self I can't really dig into it much further to know what encoding
srcds
is actually using. Perhaps its some kind of "extended ASCII", e.g. ISO 8859-1? Maybe it's UTF-8. Who knows, but I don't think we should simply guess.2d56e64 was added as a workaround for #13 but this is not ideal as it simply ignores anything it can't decode.
Looking at the two other Python RCON implementations (SourceLib and pysrcds) neither of them seem to even attempt to decode the message body, leaving it as a bytestring. Whilst no confident assertions can be made about the encoding of RCON messages there is merit to this behavior IMO.
Ultimately:
UnicodeDecodeError
should never be propagated fromMessage.decode
.Message
should expose the message body as a bytestring along side the Unicode body so that if there is any data loss from ignoring decode errors the user at least has a chance of salvaging the real message body by handling the decoding themselves or by just using the bytestring bodies exclusively.🎱
The text was updated successfully, but these errors were encountered: