Skip to content

fix: permit SGR colour in menu display text - #44

Merged
TheCryptoDonkey merged 1 commit into
mainfrom
fix/sgr-in-menu-displays
Aug 7, 2026
Merged

fix: permit SGR colour in menu display text#44
TheCryptoDonkey merged 1 commit into
mainfrom
fix/sgr-in-menu-displays

Conversation

@TheCryptoDonkey

Copy link
Copy Markdown
Member

0.16.3 removed the colour carve-out from the kindmap parser. I argued it from
RFC 1436's advice that the display field hold only printable characters "since
many different clients will be using it". That reasoning was sound and the
conclusion was wrong: it argued from the 1993 text rather than from gopherspace
as it actually is.

gopher://baud.baby/1/ builds its root menu out of truecolour SGR info lines:

i^[[38;2;27;75;105m⣶^[[38;2;40;93;127m⣿...	/	baud.baby	70

A bridge on the strict rule turns that into literal escape text, so 0.16.3
regressed proxying against a real, working hole:

before  "i<ESC>[38;2;27;75;105m⣶\t-\terror.host\t1\r\n"
after   "i [38;2;27;75;105m⣶\t-\terror.host\t1\r\n"

The rule now: a display may carry SGR and nothing else addressable; a link
carries no control character at all. A link is parsed and acted upon, a display
is only shown. That keeps the property worth keeping and stops the bridge
mangling gopherspace.

One subtlety worth calling out, because it is the same class of bug as the one
being fixed. cleanTerminalDisplay does not use stripVTControlCharacters:
removing a complete sequence and replacing each control character with a space
produce different strings, and the spec says spaces. The first version of this
change used the strip and diverged from the Python client within minutes; the
fixture caught it.

  • SPEC.md: the rule, with the reasoning for why SGR specifically.
  • fixture v3 pins both halves, what survives and what is spaced out.
  • the Python client was updated from the prose, not from this parser, and
    agrees. Its independence is weaker than for v1 and v2 since the same author
    wrote both by now; docs/nip-submission.md says so plainly rather than
    overclaiming.
  • the banner is coloured again, foreground only. The pre-0.16.3 version set
    a background on every cell and painted a near-black slab across a light
    terminal. tools/halfblock.mjs gained --ink=R,G,B, and its decode check
    caught a comma-for-semicolon bug in the sequence on the first run.

324 tests, npm run check green, Python 5/5 against the same bytes
(sha256 d461eedf…).

0.16.3 removed a colour carve-out from the kindmap parser, on the grounds that
SPEC.md forbade control characters in a display and RFC 1436 asks that the
field hold only printable characters "since many different clients will be
using it". The reasoning was sound and the conclusion was wrong, because it
argued from the 1993 text rather than from gopherspace.

gopher://baud.baby/1/ builds its root menu out of truecolour SGR info lines. A
bridge on the strict rule renders them as literal escape text, so 0.16.3
regressed proxying against a real, working hole:

  before  i<ESC>[38;2;27;75;105m⣶  ...
  after   i [38;2;27;75;105m⣶      ...

The rule is now: a display may carry SGR and nothing else addressable, a link
carries no control character at all. A link is parsed and acted upon; a display
is only shown. That keeps the property worth keeping and stops the bridge
mangling gopherspace.

cleanTerminalDisplay deliberately does not use stripVTControlCharacters:
removing a whole sequence and replacing each control character with a space
give different strings, and the specification says spaces. A second
implementation reading the prose writes the simple version, so this has to be
the simple version too. That mismatch was live for a few minutes here and is
the same class of bug as the one being fixed.

Fixture v3 pins what survives and what is spaced out. The Python client was
updated from SPEC.md prose and agrees.
@TheCryptoDonkey
TheCryptoDonkey merged commit 544562f into main Aug 7, 2026
3 checks passed
@TheCryptoDonkey
TheCryptoDonkey deleted the fix/sgr-in-menu-displays branch August 7, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant