mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-29 10:31:14 -03:00
highlight: Unicode above 0x10FFFF is an error
This should really just be using read_unquoted_escape, where this was changed in #1107
This commit is contained in:
@@ -5614,6 +5614,20 @@ static void test_highlighting() {
|
||||
highlight_tests.push_back({{L"$EMPTY_VARIABLE", highlight_role_t::error}});
|
||||
highlight_tests.push_back({{L"\"$EMPTY_VARIABLE\"", highlight_role_t::error}});
|
||||
|
||||
highlight_tests.push_back({
|
||||
{L"echo", highlight_role_t::command},
|
||||
{L"\\UFDFD", highlight_role_t::escape},
|
||||
});
|
||||
#if WCHAR_T_BITS > 16
|
||||
highlight_tests.push_back({
|
||||
{L"echo", highlight_role_t::command},
|
||||
{L"\\U10FFFF", highlight_role_t::escape},
|
||||
});
|
||||
highlight_tests.push_back({
|
||||
{L"echo", highlight_role_t::command},
|
||||
{L"\\U110000", highlight_role_t::error},
|
||||
});
|
||||
#endif
|
||||
const auto saved_flags = fish_features();
|
||||
mutable_fish_features().set(features_t::ampersand_nobg_in_token, true);
|
||||
for (const highlight_component_list_t &components : highlight_tests) {
|
||||
|
||||
@@ -602,6 +602,8 @@ static void color_string_internal(const wcstring &buffstr, highlight_spec_t base
|
||||
case L'U': {
|
||||
chars = 8;
|
||||
max_val = WCHAR_MAX;
|
||||
// Don't exceed the largest Unicode code point - see #1107.
|
||||
if (0x10FFFF < max_val) max_val = static_cast<wchar_t>(0x10FFFF);
|
||||
in_pos++;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user