[BUG] Bare-URL linkifier swallows fullwidth punctuation and CJK text into OSC 8 hyperlinks
Environment
- Claude Code v2.1.211 (native build, macOS)
- Any OSC 8-capable terminal (reproduced in an xterm.js-based terminal advertising
FORCE_HYPERLINK=1; the same range bug also affects the plain underline styling in other terminals)
Description
When assistant output contains a bare URL immediately followed by fullwidth punctuation or CJK characters (very common in Chinese/Japanese responses, where no ASCII space separates the URL from (, ), :, ,, 。), the URL auto-linkifier extends the link through the CJK text until the next whitespace. Both the underline styling and the OSC 8 URI include the trailing CJK characters, so clicking the link opens a broken URL.
Examples from real output:
PR: https://github.com/sgl-project/sglang/pull/31494(two commits)-> link/URI becomeshttps://github.com/sgl-project/sglang/pull/31494(two(preview: http://localhost:6420):-> link/URI becomeshttp://localhost:6420):
Root cause
The bare-URL detection regex in the message renderer is:
/https?:\/\/[^\s"'<>\\…\x00-\x1f]+/g
The negated class excludes whitespace, quotes, angle brackets, backslash, … (U+2026), and control chars — but not fullwidth punctuation (U+FF08 (, U+FF09 ), U+FF1A :, U+3002 。, ...) or CJK ideographs, so they all match until the next whitespace.
The trailing-trim pass only handles ASCII: it strips .,;:!? and unbalanced )/]/} (via a {")": "(", "]": "[", "}": "{"} pair map), so the fullwidth equivalents survive.
Steps to reproduce
- Run
claudein an OSC 8-capable terminal (or withFORCE_HYPERLINK=1). - Have the assistant output a line containing literally:
see https://github.com/anthropics/claude-code/pull/123(two commits) - Hover/click the link.
Expected: link range and URI stop at .../pull/123.
Actual: link range and URI are .../pull/123(two; the opened URL is broken.
Suggested fix
Add fullwidth/CJK punctuation to the excluded class (the regex already special-cases …), or more robustly exclude all non-ASCII from the URL match tail — e.g. stop at [^\x21-\x7e] after the scheme — and/or extend the trailing-trim to the fullwidth counterparts ():,。?!.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗