Merge pull request #31514 from CodethinkLabs/ptyfwd_issues
ptyfwd/terminal-util: improve edge case handling
This commit is contained in:
+14
-4
@@ -270,7 +270,9 @@ static int insert_newline_color_erase(PTYForward *f, size_t offset) {
|
||||
_cleanup_free_ char *s = NULL;
|
||||
|
||||
assert(f);
|
||||
assert(f->background_color);
|
||||
|
||||
if (!f->background_color)
|
||||
return 0;
|
||||
|
||||
/* When we see a newline (ASCII 10) then this sets the background color to the desired one, and erase the rest
|
||||
* of the line with it */
|
||||
@@ -289,7 +291,9 @@ static int insert_carriage_return_color(PTYForward *f, size_t offset) {
|
||||
_cleanup_free_ char *s = NULL;
|
||||
|
||||
assert(f);
|
||||
assert(f->background_color);
|
||||
|
||||
if (!f->background_color)
|
||||
return 0;
|
||||
|
||||
/* When we see a carriage return (ASCII 13) this this sets only the background */
|
||||
|
||||
@@ -503,9 +507,15 @@ static int pty_forward_ansi_process(PTYForward *f, size_t offset) {
|
||||
} else if (!strextend(&f->osc_sequence, CHAR_TO_STR(c)))
|
||||
return -ENOMEM;
|
||||
} else {
|
||||
/* Otherwise, the OSC sequence is over */
|
||||
/* Otherwise, the OSC sequence is over
|
||||
*
|
||||
* There are two allowed ways to end an OSC sequence:
|
||||
* BEL '\x07'
|
||||
* String Terminator (ST): <Esc>\ - "\x1b\x5c"
|
||||
* since we cannot lookahead to see if the Esc is followed by a \
|
||||
* we cut a corner here and assume it will be \. */
|
||||
|
||||
if (c == '\x07') {
|
||||
if (c == '\x07' || c == '\x1b') {
|
||||
r = insert_window_title_fix(f, i+1);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
Reference in New Issue
Block a user