mirror of
https://github.com/microsoft/terminal.git
synced 2026-02-04 01:04:40 +00:00
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
This commit is contained in:
@@ -125,10 +125,10 @@ void AdaptDispatch::_SetRgbColorsHelperFromSubParams(const VTParameter colorItem
|
||||
// sub params are in the order:
|
||||
// :2:<color-space-id>:<r>:<g>:<b>
|
||||
|
||||
// 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) });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user