Repository navigation
Strip 8-bit C1 controls in Vt100_Output.write and set_title - #2152
Open
neeraj1235476 wants to merge 1 commit into
Open
neeraj1235476 wants to merge 1 commit into
neeraj1235476 wants to merge 1 commit into
Conversation
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.
Vt100_Output.write()is whatprint_formatted_text()uses for plain text, and its docstring says it removes vt100 escape codes, but it only replaces ESC. The 8-bit C1 introducers (CSI\x9b, OSC\x9d, DCS\x90, ST\x9c, ...) go straight to the terminal, and xterm and VTE-based terminals act on them in UTF-8 mode. Soprint_formatted_text("\x9b2J\x9b31m...")with untrusted text (a filename, a server response, output sent to a telnet/ssh client) clears the screen or changes styling.set_title()has the same gap: it strips ESC and BEL, but a\x9cin the title ends the OSC early, and anything after it is written as raw output.write()now also replaces\x80-\x9fwith?, the same as ESC. Most text is ASCII, so anisascii()check keeps that path at a singlestr.replace.set_title()drops the same range. The layoutScreenalready shows these characters as<9b>etc., so this only brings the direct-write path in line with it. Tests are added intests/test_vt100_output.py.