Skip to content

Commit c4e9901

Browse files
sahrizviclaude
andcommitted
fix: address round-2 bot review findings on #1274 — Apple_Terminal false positive, C1 control bytes
- `terminalSupportsHyperlinks`: drop `Apple_Terminal` from the allowlist. macOS Terminal.app only gained OSC 8 support in Sequoia (Sept 2024); older versions only auto-linkify plain URLs. `TERM_PROGRAM` alone can't tell a Sequoia+ install apart from an older one, and this function's own documented bias is toward false negatives — so it's excluded rather than assumed current. Verified via search before reverting; my earlier inclusion was an unverified assumption. (Kilo) - `stripControlChars`: extend the stripped range to also cover C1 control bytes (`\x80`-`\x9f`), not just C0 + DEL. ESC (the actual OSC 8 breakout vector) was always covered, but the doc comment overstated what the regex did. (Kilo) Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JsVwcBQP6VUwqEej3vK2zG
1 parent 6fb1c43 commit c4e9901

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

  • packages/opencode/src/cli/cmd

‎packages/opencode/src/cli/cmd/link.ts‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ const SET_UP_IN_BROWSER_SENTINEL = "__browser_handoff__"
5050
* they choose, with our trusted URL as the visible (but inert) prefix.
5151
* (CodeRabbit + cubic, PR #1274.) */
5252
function stripControlChars(text: string): string {
53+
// C0 (\x00-\x1f) + DEL (\x7f) + C1 (\x80-\x9f) — the previous range only
54+
// covered C0/DEL, leaving C1 controls unstripped. ESC (the OSC 8 breakout
55+
// vector) was always covered, but the doc comment claimed C1 coverage it
56+
// didn't have. (Kilo, PR #1274.)
5357
// eslint-disable-next-line no-control-regex
54-
return text.replace(/[\x00-\x1f\x7f]/g, "")
58+
return text.replace(/[\x00-\x1f\x7f-\x9f]/g, "")
5559
}
5660

5761
/** Conservative allowlist of terminals known to render OSC 8 hyperlinks.
@@ -61,15 +65,21 @@ function stripControlChars(text: string): string {
6165
* plain text instead of a link, which is a strict improvement over the
6266
* inverse (underlining text that turns out not to be clickable). Mirrors the
6367
* checks the `supports-hyperlinks` package uses, inlined to avoid a new
64-
* dependency for one CLI affordance. */
68+
* dependency for one CLI affordance.
69+
*
70+
* Deliberately excludes ``Apple_Terminal`` (macOS Terminal.app): OSC 8
71+
* support only landed there in macOS Sequoia (Sept 2024) — older versions
72+
* (Ventura/Sonoma and earlier) only auto-linkify plain-text URLs, not OSC 8.
73+
* ``TERM_PROGRAM`` carries no OS/Terminal-version signal to tell those apart,
74+
* and this function's own stated bias is toward false negatives, so it's
75+
* left off the list rather than guessing the user is on a current-enough
76+
* macOS. (Kilo, PR #1274 — corrects an earlier version of this list that
77+
* included it.) */
6578
function terminalSupportsHyperlinks(): boolean {
6679
if (!process.stdout.isTTY) return false
6780
if (process.env.TERM === "dumb" || process.env.TERM === "linux") return false
6881
const termProgram = process.env.TERM_PROGRAM
69-
if (
70-
termProgram &&
71-
["iTerm.app", "WezTerm", "Hyper", "vscode", "ghostty", "Tabby", "rio", "Apple_Terminal"].includes(termProgram)
72-
)
82+
if (termProgram && ["iTerm.app", "WezTerm", "Hyper", "vscode", "ghostty", "Tabby", "rio"].includes(termProgram))
7383
return true
7484
if (process.env.WT_SESSION) return true // Windows Terminal
7585
if (process.env.KONSOLE_VERSION) return true

0 commit comments

Comments
 (0)