diff options
| author | Maxime Coste <mawww@kakoune.org> | 2024-10-28 12:21:09 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2024-10-28 12:21:09 +1100 |
| commit | be82047dbf5f74f123e925b96e0e13962a4e0c09 (patch) | |
| tree | 2d0313edab8e6eecd1fd712ece572f990eef0b48 /src/command_manager.cc | |
| parent | b96e500ddb27f78f2478e69836d6502d4fdbe9c0 (diff) | |
Only check for ascii horizontal blanks during command parsing
The general is_horizontal_blank supports various unicode blanks,
but passing an utf8 continuation byte to it can lead to surprising
results as we can match with 0xA0 (when char is unsigned).
Fixes #5250
Diffstat (limited to 'src/command_manager.cc')
| -rw-r--r-- | src/command_manager.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/command_manager.cc b/src/command_manager.cc index e30f8a68..0db97e94 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -179,6 +179,13 @@ ParseResult parse_quoted_balanced(ParseState& state) return {String{String::NoCopy{}, {beg, pos - terminated}}, terminated}; } +bool is_ascii_horizontal_blank(char c) +{ + return c == '\t' or + c == '\f' or + c == ' '; +} + String parse_unquoted(ParseState& state) { const char* beg = state.pos; @@ -189,7 +196,7 @@ String parse_unquoted(ParseState& state) while (state.pos != end) { const char c = *state.pos; - if (is_command_separator(c) or is_horizontal_blank(c)) + if (is_command_separator(c) or is_ascii_horizontal_blank(c)) { str += StringView{beg, state.pos}; if (state.pos != beg and *(state.pos - 1) == '\\') @@ -235,8 +242,8 @@ void skip_blanks_and_comments(ParseState& state) { while (state) { - const Codepoint c = *state.pos; - if (is_horizontal_blank(c)) + const char c = *state.pos; + if (is_ascii_horizontal_blank(c)) ++state.pos; else if (c == '\\' and state.pos + 1 != state.str.end() and state.pos[1] == '\n') |
