1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 07:22:43 +01:00

Merge pull request #13110 from NixOS/mergify/bp/2.28-maintenance/pr-13109

libutil: amend OSC 8 escape stripping for xterm-style separator (backport #13109)
This commit is contained in:
Jörg Thalheim 2025-05-01 08:11:47 +02:00 committed by GitHub
commit bf0f35ec69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 4 deletions

View file

@ -95,10 +95,19 @@ std::string filterANSIEscapes(std::string_view s, bool filterAll, unsigned int w
} else if (i != s.end() && *i == ']') {
// OSC
e += *i++;
// eat ESC
while (i != s.end() && *i != '\e') e += *i++;
// eat backslash
if (i != s.end() && *i == '\\') e += last = *i++;
// https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda defines
// two forms of a URI separator:
// 1. ESC '\' (standard)
// 2. BEL ('\a') (xterm-style, used by gcc)
// eat ESC or BEL
while (i != s.end() && *i != '\e' && *i != '\a') e += *i++;
if (i != s.end()) {
char v = *i;
e += *i++;
// eat backslash after ESC
if (i != s.end() && v == '\e' && *i == '\\') e += last = *i++;
}
} else {
if (i != s.end() && *i >= 0x40 && *i <= 0x5f) e += *i++;
}