From c8549bebedb992d7014e9f8f84783e067141d7c0 Mon Sep 17 00:00:00 2001 From: Vallabh Mahajan <168367584+Vallabh-1504@users.noreply.github.com> Date: Fri, 23 Jan 2026 22:51:55 +0530 Subject: [PATCH] sgr: consider ITU T.416 colors with color space 0 valid (#19768) This PR fixes an issue where SGR color sequences containing a Color Space ID of 0 (e.g., \e[38:2:0:r:g:bm) were incorrectly rejected as invalid. According to ITU T.416, the Color Space ID parameter is defined, and a value of 0 is implementation-defined. It is widely accepted by other terminal emulators (like XTerm) as the default RGB color space. This change modifies the check to explicitly allow an ID of 0 while still rejecting other non-standard IDs, ensuring compatibility with tools that emit fully qualified T.416 sequences. Closes #19547 --- src/terminal/adapter/adaptDispatchGraphics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/terminal/adapter/adaptDispatchGraphics.cpp b/src/terminal/adapter/adaptDispatchGraphics.cpp index 6c0666eae6..fff34ac2aa 100644 --- a/src/terminal/adapter/adaptDispatchGraphics.cpp +++ b/src/terminal/adapter/adaptDispatchGraphics.cpp @@ -125,10 +125,10 @@ void AdaptDispatch::_SetRgbColorsHelperFromSubParams(const VTParameter colorItem // sub params are in the order: // :2:::: - // We treat a color as invalid if it has a non-empty color space ID, as + // We treat a color as invalid if it has a non-zero color space ID, as // some applications that support non-standard ODA color sequence might // send the red value in its place. - const bool hasColorSpaceId = options.at(1).has_value(); + const bool validColorSpace = options.at(1).value_or(0) == 0; const size_t red = options.at(2).value_or(0); const size_t green = options.at(3).value_or(0); @@ -136,7 +136,7 @@ void AdaptDispatch::_SetRgbColorsHelperFromSubParams(const VTParameter colorItem // We only apply the color if the R, G, B values fit within a byte. // This is to match XTerm's and VTE's behavior. - if (!hasColorSpaceId && red <= 255 && green <= 255 && blue <= 255) + if (validColorSpace && red <= 255 && green <= 255 && blue <= 255) { applyColor(TextColor{ RGB(red, green, blue) }); }