diff options
| author | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-01-18 21:36:56 +0100 |
|---|---|---|
| committer | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-01-18 21:36:56 +0100 |
| commit | 3deb2b3970cb344d0c615e9d41a5fe7f3baf1417 (patch) | |
| tree | 144aa3f120d4276aa5d15496c8927ed050350af7 /src/cmdline.c | |
| parent | b5dac044ddda2d2057d1d785d5827c1b890c90b6 (diff) | |
fixed auto-completion of Unicode file names
* teco_string_diff() could return a number of bytes in the middle of
an Unicode sequence. It now also requires Unicode strings.
* Added a missing Unicode-validity check when replacing command lines (`{` and `}`).
teco_cmdline_insert() should really be refactored, though (FIXME).
* Added test case
Diffstat (limited to 'src/cmdline.c')
| -rw-r--r-- | src/cmdline.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/cmdline.c b/src/cmdline.c index fa69d91..9a7b356 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -162,12 +162,32 @@ teco_cmdline_insert(const gchar *data, gsize len, GError **error) * Result of command line replacement (}): * Exchange command lines */ + g_clear_error(&tmp_error); + teco_qreg_t *cmdline_reg = teco_qreg_table_find(&teco_qreg_table_globals, "\e", 1); g_auto(teco_string_t) new_cmdline = {NULL, 0}; if (!cmdline_reg->vtable->get_string(cmdline_reg, &new_cmdline.data, &new_cmdline.len, - NULL, error)) + NULL, &tmp_error)) { + teco_error_add_frame_toplevel(); + teco_error_display_short(tmp_error); + g_propagate_error(error, g_steal_pointer(&tmp_error)); return FALSE; + } + + /* + * SciTECO code must always be UTF-8, but you can smuggle arbitrary bytes + * into the "\e" register. + * This would be cumbersome to test for in teco_state_start_cmdline_pop(). + */ + if (!teco_string_validate_utf8(new_cmdline)) { + g_set_error_literal(&tmp_error, TECO_ERROR, TECO_ERROR_CODEPOINT, + "Invalid UTF-8 byte sequence in command-line replacement"); + teco_error_add_frame_toplevel(); + teco_error_display_short(tmp_error); + g_propagate_error(error, g_steal_pointer(&tmp_error)); + return FALSE; + } /* * Search for first differing character in old and @@ -229,7 +249,7 @@ teco_cmdline_insert(const gchar *data, gsize len, GError **error) } } - /* error is handled in teco_cmdline_keypress_c() */ + /* error is handled in teco_cmdline_keypress() */ g_propagate_error(error, g_steal_pointer(&tmp_error)); return FALSE; } |
