Surrogates in UTF-8 encoding causes an unhandled exception in [p]debug
#6485
Labels
Category: Cogs - Dev
This is related to the Dev cog.
Status: PRs Welcome
No one is currently assigned to this issue, but we'd be grateful if anyone made a PR.
Type: Bug
Unexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing.
What Red version are you using?
3.5.13
Cog name
Dev
Command name
debug
What did you expect to happen?
A traceback to be gracefully sent as exception detail.
What actually happened?
The command itself errored:
How can we reproduce this error?
--dev
flag.[p]debug "\uD800"
in any locationAnything else?
While the traceback suggests that this error can occur more broadly through
Context.send
, the root cause in that case would lie with the developer, as surrogate characters are prohibited in UTF-8 encoding (they are designed for UTF-16). For debugging purposes, I feel it would be necessary for the exception to be included in the debug output rather than being raised, so that the command doesn't fail. This would allow this invalid debugging statement to be gracefully evaluated. This exception may be reproduced for any surrogate characters (unicode code points beyond the basic multilingual plane).Possible workarounds could include pre-validation/sanitization of the raw source, probably best fitted inside
dev_commands.sanitize_output
.The text was updated successfully, but these errors were encountered: