From 32732823475676a1b28aa0fb6329f6fb45a3e125 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 26 Jul 2025 09:39:09 +0200 Subject: [PATCH] Parse DCS and OSC commands As reported in https://github.com/fish-shell/fish-shell/issues/11609#issuecomment-3114092441, a Proxmox Terminal (https://git.proxmox.com/git/novnc-pve) fails to parse OSC commands such as: bash$ printf '\x1b]133;A;click_events=1\x07' Judging by the Git history of the novnc-pve repo, it looks like they use websockify-js. They no longer vendor VT100.js, so hopefully we only need to fix this here. Untested (happy to do that; not yet sure how). --- include/VT100.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/VT100.js b/include/VT100.js index 6a325e1..f1b5708 100644 --- a/include/VT100.js +++ b/include/VT100.js @@ -697,6 +697,11 @@ VT100.prototype.write = function(stuff) this.esc_state_ = 2; this.debug("write:: set escape state: 2"); break; + case ']': + case 'P': + this.esc_state_ = 7; + this.debug("write:: set escape state: 7"); + break; case '=': /* Set keypade mode (ignored) */ this.debug("write:: set keypade mode: ignored"); @@ -903,6 +908,28 @@ VT100.prototype.write = function(stuff) this.esc_state_ = 0; this.debug("write:: set escape state: 0"); break; + case 7: // DCS, OSC + switch (ch) { + case '\x07': // BEL + case '\x9c': // ST + this.esc_state_ = 0; + this.debug("write:: set escape state: 0"); + break; + case '\x1b': // ST + this.esc_state = 8; + this.debug("write:: set escape state: 8"); + break; + } + case 8: // Maybe in ST + switch (ch) { + case '\x5c': + this.esc_state = 0; + this.debug("write:: set escape state: 0"); + break; + default: + this.esc_state = 7; + break; + } } } this.refresh();