Commit 0ceb6f1c11bf097f766cc238801a9dd9b7328e35
Fix escaping characters with codes > 127
When `char` is signed and holds a value >= 0x80, casting it to an `int`
instead of `unsigned char` first results in a negative number.
One way to trigger this is by escaping a UTF-8 character.
Author: xaizek
Author date (UTC): 2025-07-05 12:46
Committer name: xaizek
Committer date (UTC): 2025-07-05 13:11
Parent(s): 91c59fff4429227c08bf1694273763c176b70b8c
Signing key: 99DC5E4DB05F6BE2
Tree: 0db34ee1b6161db816b30caf376950e37cecf970
File ChangeLog changed (mode: 100644) (index b49503ba7..5cbfb8f69) |
112 |
112 |
|
|
113 |
113 |
Fixed :normal not being able to run commands which end with whitespace. |
Fixed :normal not being able to run commands which end with whitespace. |
114 |
114 |
|
|
|
115 |
|
Fixed escaping characters with codes greater than 127 producing garbage. |
|
116 |
|
|
115 |
117 |
0.14-beta to 0.14 (2025-02-08) |
0.14-beta to 0.14 (2025-02-08) |
116 |
118 |
|
|
117 |
119 |
Improved documentation on zh/zl menu keys a bit. |
Improved documentation on zh/zl menu keys a bit. |
File src/engine/parsing.c changed (mode: 100644) (index 75c0ff1ad..746475e39) |
... |
... |
parse_doubly_quoted_char(parse_context_t *ctx, const char **in, sbuffer *sbuf) |
1108 |
1108 |
return 0; |
return 0; |
1109 |
1109 |
} |
} |
1110 |
1110 |
ok = sstrappendch(sbuf->data, &sbuf->len, sbuf->size, |
ok = sstrappendch(sbuf->data, &sbuf->len, sbuf->size, |
1111 |
|
table[(int)ctx->last_token.c]); |
|
|
1111 |
|
table[(unsigned char)ctx->last_token.c]); |
1112 |
1112 |
} |
} |
1113 |
1113 |
else |
else |
1114 |
1114 |
{ |
{ |
File src/utils/utils.c changed (mode: 100644) (index 119b604c9..86eed474b) |
... |
... |
expand_dquotes_escaping(char s[]) |
800 |
800 |
LOG_ERROR_MSG("Escaped eol in \"%s\"", str); |
LOG_ERROR_MSG("Escaped eol in \"%s\"", str); |
801 |
801 |
break; |
break; |
802 |
802 |
} |
} |
803 |
|
*p++ = table[(int)*s++]; |
|
|
803 |
|
*p++ = table[(unsigned char)*s++]; |
804 |
804 |
} |
} |
805 |
805 |
*p = '\0'; |
*p = '\0'; |
806 |
806 |
} |
} |
File tests/cmds/input.c changed (mode: 100644) (index 679a554f5..831096077) |
... |
... |
TEST(non_printable_arg) |
739 |
739 |
assert_string_equal("\x0C", arg); |
assert_string_equal("\x0C", arg); |
740 |
740 |
} |
} |
741 |
741 |
|
|
|
742 |
|
TEST(escaping_char_with_highest_bit) |
|
743 |
|
{ |
|
744 |
|
assert_int_equal(0, vle_cmds_run("delete \"\\\x80 \\\xff\"")); |
|
745 |
|
assert_string_equal("\x80 \xff", arg); |
|
746 |
|
} |
|
747 |
|
|
742 |
748 |
TEST(closing_double_quote_is_taken_as_comment) |
TEST(closing_double_quote_is_taken_as_comment) |
743 |
749 |
{ |
{ |
744 |
750 |
/* That's result of ambiguity of parsing, instead real :set doesn't have |
/* That's result of ambiguity of parsing, instead real :set doesn't have |
File tests/parsing/double_quotes.c changed (mode: 100644) (index 1ec0302ce..84b693d63) |
... |
... |
TEST(dot_ok) |
51 |
51 |
ASSERT_OK("\"a . c\"", "a . c"); |
ASSERT_OK("\"a . c\"", "a . c"); |
52 |
52 |
} |
} |
53 |
53 |
|
|
|
54 |
|
TEST(escaping_char_with_highest_bit) |
|
55 |
|
{ |
|
56 |
|
ASSERT_OK("\"\\\x80 \\\xff\"", "\x80 \xff"); |
|
57 |
|
} |
|
58 |
|
|
54 |
59 |
TEST(very_long_string) |
TEST(very_long_string) |
55 |
60 |
{ |
{ |
56 |
61 |
char string[8192]; |
char string[8192]; |