Bug 499122 - OSC 4 response uses incorrect terminator character
Summary: OSC 4 response uses incorrect terminator character
Status: REPORTED
Alias: None
Product: konsole
Classification: Applications
Component: emulation (show other bugs)
Version: master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-25 09:42 UTC by Egmont Koblinger
Modified: 2025-01-25 09:42 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Egmont Koblinger 2025-01-25 09:42:48 UTC
SUMMARY
OSC 4 response (to get the RGB value of a particular palette color) uses incorrect terminator character, BEL instead of ST.

The official terminator for OSC is ST, that is, ESC followed by Backslash. BEL is a nonstandard variant used sometimes.

For OSC 10 and 11 queries (to get the RGB value of the default foreground and background colors), Konsole echoes back the terminator seen in the query. For OSC 4 the response always contains the incorrect terminator. So Konsole is even inconsistent with itself.

When parsing such sequences, it's great that Konsole accepts both variants. When emitting, please be consistent: either always echo back the query's format (as you do now for OSC 10/11), or maybe always use the correct format (for all of OSC 4/10/11, then). But please don't respond to a correct query with an incorrect response.

STEPS TO REPRODUCE

Run this script:

#!/bin/bash
stty raw
printf '\e]4;0;?\e\\'
IFS='' read -r -t 1
stty cooked
echo

This emits an OSC 4 query (asking for the RGB value of palette index 0 in this example), to which the terminal responds with an OSC 4 as if you'd typed it from your keyboard.

For your convenience, this little script makes the response appear in the terminal, and reads and swallows those characters so that they don't mess with your next command.

OBSERVED RESULT

^[]4;0;rgb:0000/0000/0000^G

EXPECTED RESULT

^[]4;0;rgb:0000/0000/0000^[\

(The actual color might differ,  of course.)

SOFTWARE/OS VERSIONS
Konsole version 09f91397188 (just built from git master)