mirror of
https://github.com/NixOS/nix
synced 2025-06-25 14:51:16 +02:00
Merge pull request #12136 from NixOS/mergify/bp/2.24-maintenance/pr-11876
Filter OSC 8 correctly (backport #11876)
This commit is contained in:
commit
b59b317e47
2 changed files with 12 additions and 0 deletions
|
@ -45,6 +45,13 @@ std::string filterANSIEscapes(std::string_view s, bool filterAll, unsigned int w
|
||||||
while (i != s.end() && *i >= 0x20 && *i <= 0x2f) e += *i++;
|
while (i != s.end() && *i >= 0x20 && *i <= 0x2f) e += *i++;
|
||||||
// eat final byte
|
// eat final byte
|
||||||
if (i != s.end() && *i >= 0x40 && *i <= 0x7e) e += last = *i++;
|
if (i != s.end() && *i >= 0x40 && *i <= 0x7e) e += last = *i++;
|
||||||
|
} 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++;
|
||||||
} else {
|
} else {
|
||||||
if (i != s.end() && *i >= 0x40 && *i <= 0x5f) e += *i++;
|
if (i != s.end() && *i >= 0x40 && *i <= 0x5f) e += *i++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -700,4 +700,9 @@ namespace nix {
|
||||||
ASSERT_EQ(filterANSIEscapes("f𐍈𐍈bär", true, 4), "f𐍈𐍈b");
|
ASSERT_EQ(filterANSIEscapes("f𐍈𐍈bär", true, 4), "f𐍈𐍈b");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(filterANSIEscapes, osc8)
|
||||||
|
{
|
||||||
|
ASSERT_EQ(filterANSIEscapes("\e]8;;http://example.com\e\\This is a link\e]8;;\e\\"), "This is a link");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue