ScuttleBot
fix: filter bracketed paste mode escapes from PTY mirror [?2026l and [?2026h sequences were leaking into IRC when split across read chunks. Added pattern to both ansiRE and noiseRE.
Commit
46ba17d882f9a5520a8f99ff7e4c80b6943b37191109d9d47f4ff2f89648758f
Parent
8a95200b21bc8b3…
1 file changed
+3
-3
+3
-3
| --- pkg/relaymirror/pty.go | ||
| +++ pkg/relaymirror/pty.go | ||
| @@ -11,15 +11,15 @@ | ||
| 11 | 11 | "strings" |
| 12 | 12 | "sync" |
| 13 | 13 | "time" |
| 14 | 14 | ) |
| 15 | 15 | |
| 16 | -// ansiRE matches ANSI escape sequences. | |
| 17 | -var ansiRE = regexp.MustCompile(`\x1b\[[0-9;]*[a-zA-Z]|\x1b\].*?\x07|\x1b\(B`) | |
| 16 | +// ansiRE matches ANSI escape sequences (including partial/split ones). | |
| 17 | +var ansiRE = regexp.MustCompile(`\x1b\[[0-9;?]*[a-zA-Z]|\x1b\].*?\x07|\x1b\(B|\[\?[0-9]+[hl]`) | |
| 18 | 18 | |
| 19 | 19 | // noiseRE matches common terminal noise: spinner chars, progress bars, cursor movement. |
| 20 | -var noiseRE = regexp.MustCompile(`^[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏\-\\|/]+$|^\s*\d+%\s*$|^[.]+$`) | |
| 20 | +var noiseRE = regexp.MustCompile(`^[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏\-\\|/]+$|^\s*\d+%\s*$|^[.]+$|^\[?\?[0-9]+[hl]`) | |
| 21 | 21 | |
| 22 | 22 | // PTYMirror reads PTY output and emits clean text lines to IRC. |
| 23 | 23 | // It includes rate limiting and noise filtering for clean IRC output. |
| 24 | 24 | type PTYMirror struct { |
| 25 | 25 | maxLineLen int |
| 26 | 26 |
| --- pkg/relaymirror/pty.go | |
| +++ pkg/relaymirror/pty.go | |
| @@ -11,15 +11,15 @@ | |
| 11 | "strings" |
| 12 | "sync" |
| 13 | "time" |
| 14 | ) |
| 15 | |
| 16 | // ansiRE matches ANSI escape sequences. |
| 17 | var ansiRE = regexp.MustCompile(`\x1b\[[0-9;]*[a-zA-Z]|\x1b\].*?\x07|\x1b\(B`) |
| 18 | |
| 19 | // noiseRE matches common terminal noise: spinner chars, progress bars, cursor movement. |
| 20 | var noiseRE = regexp.MustCompile(`^[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏\-\\|/]+$|^\s*\d+%\s*$|^[.]+$`) |
| 21 | |
| 22 | // PTYMirror reads PTY output and emits clean text lines to IRC. |
| 23 | // It includes rate limiting and noise filtering for clean IRC output. |
| 24 | type PTYMirror struct { |
| 25 | maxLineLen int |
| 26 |
| --- pkg/relaymirror/pty.go | |
| +++ pkg/relaymirror/pty.go | |
| @@ -11,15 +11,15 @@ | |
| 11 | "strings" |
| 12 | "sync" |
| 13 | "time" |
| 14 | ) |
| 15 | |
| 16 | // ansiRE matches ANSI escape sequences (including partial/split ones). |
| 17 | var ansiRE = regexp.MustCompile(`\x1b\[[0-9;?]*[a-zA-Z]|\x1b\].*?\x07|\x1b\(B|\[\?[0-9]+[hl]`) |
| 18 | |
| 19 | // noiseRE matches common terminal noise: spinner chars, progress bars, cursor movement. |
| 20 | var noiseRE = regexp.MustCompile(`^[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏\-\\|/]+$|^\s*\d+%\s*$|^[.]+$|^\[?\?[0-9]+[hl]`) |
| 21 | |
| 22 | // PTYMirror reads PTY output and emits clean text lines to IRC. |
| 23 | // It includes rate limiting and noise filtering for clean IRC output. |
| 24 | type PTYMirror struct { |
| 25 | maxLineLen int |
| 26 |