From ed7652db5056c3658afbc11c04e164e77da18650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 25 Aug 2025 14:26:44 +0200 Subject: [PATCH 1/9] config: value_to_*(): don't overwrite result variable on error Some of the value_to_*() functions wrote directly to the output variable, even when the value was invalid. This often resulted in the an actual configuration option (i.e. a member in the config struct) to be overwritten by an invalid value. For example, -o initial-color-theme=0 would set conf->initial_color_theme to -1, resulting in a crash later, when initializing a terminal instance. --- CHANGELOG.md | 7 ++++++- config.c | 20 ++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd5730a1..2a2e3347 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,7 +70,7 @@ ### Changed * The label letters are no longer sorted before being assigned to URLs - ([#2140]2140[]). + ([#2140][2140]). * Sending SIGUSR1/SIGUSR2 to a `foot --server` process now causes newly spawned client instances to use the selected theme, instead of the original one. @@ -83,6 +83,11 @@ ### Deprecated ### Removed ### Fixed + +* Invalid configuration values overriding valid ones in surprising + ways. + + ### Security ### Contributors diff --git a/config.c b/config.c index 77dc3a73..1d539bcb 100644 --- a/config.c +++ b/config.c @@ -474,8 +474,12 @@ str_to_ulong(const char *s, int base, unsigned long *res) errno = 0; char *end = NULL; - *res = strtoul(s, &end, base); - return errno == 0 && *end == '\0'; + unsigned long v = strtoul(s, &end, base); + if (!(errno == 0 && *end == '\0')) + return false; + + *res = v; + return true; } static bool NOINLINE @@ -544,12 +548,13 @@ value_to_float(struct context *ctx, float *res) errno = 0; char *end = NULL; - *res = strtof(s, &end); + float v = strtof(s, &end); if (!(errno == 0 && *end == '\0')) { LOG_CONTEXTUAL_ERR("invalid decimal value"); return false; } + *res = v; return true; } @@ -641,7 +646,6 @@ value_to_enum(struct context *ctx, const char **value_map, int *res) valid_values[idx - 2] = '\0'; LOG_CONTEXTUAL_ERR("not one of %s", valid_values); - *res = -1; return false; } @@ -690,14 +694,18 @@ value_to_two_colors(struct context *ctx, goto out; } + uint32_t a, b; + ctx->value = first_as_str; - if (!value_to_color(ctx, first, allow_alpha)) + if (!value_to_color(ctx, &a, allow_alpha)) goto out; ctx->value = second_as_str; - if (!value_to_color(ctx, second, allow_alpha)) + if (!value_to_color(ctx, &b, allow_alpha)) goto out; + *first = a; + *second = b; ret = true; out: From f0e36e35cb65bdb92dbe24d00a9cc6bc8d72a458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 30 Aug 2025 08:18:31 +0200 Subject: [PATCH 2/9] input: unit test: check pipe2() return value Fixes compilation failures with clang, in release mode. --- input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input.c b/input.c index fe90a7f0..fe5a8001 100644 --- a/input.c +++ b/input.c @@ -1878,7 +1878,7 @@ keyboard_modifiers(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, UNITTEST { int chan[2]; - pipe2(chan, O_CLOEXEC); + xassert(pipe2(chan, O_CLOEXEC) == 0); xassert(chan[0] >= 0); xassert(chan[1] >= 0); From 298196365c06c13dd16a74e34e03d9de93670473 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Thu, 7 Aug 2025 08:18:38 -0400 Subject: [PATCH 3/9] config: add 'uppercase-regex-insert' This makes the "uppercase hint character inserts selected text" behavior added in #1975 configurable, as it can have unexpected behavior for some users. It defaults to "on", preserving the new behavior of `foot`, after Fixes #2159. --- CHANGELOG.md | 7 +++++++ config.c | 4 ++++ config.h | 1 + doc/foot.ini.5.scd | 7 +++++++ foot.ini | 2 ++ tests/test-config.c | 1 + url-mode.c | 3 ++- 7 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a2e3347..57144549 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,13 @@ ## Unreleased ### Added + +* The `uppercase-regex-insert` option controls whether an uppercase hint + character will insert the selected text into the prompt in `regex-copy` + or `show-urls-copy` mode. It defaults to `true`. ([#2159][2159]). + +[2159]: https://codeberg.org/dnkl/foot/issues/2159 + ### Changed * The label letters are no longer sorted before being assigned to URLs diff --git a/config.c b/config.c index 1d539bcb..0de1a1be 100644 --- a/config.c +++ b/config.c @@ -1119,6 +1119,9 @@ parse_section_main(struct context *ctx) (int *)&conf->initial_color_theme); } + else if (streq(key, "uppercase-regex-insert")) + return value_to_bool(ctx, &conf->uppercase_regex_insert); + else { LOG_CONTEXTUAL_ERR("not a valid option: %s", key); return false; @@ -3383,6 +3386,7 @@ config_load(struct config *conf, const char *conf_path, .strikeout_thickness = {.pt = 0., .px = -1}, .dpi_aware = false, .gamma_correct = false, + .uppercase_regex_insert = true, .security = { .osc52 = OSC52_ENABLED, }, diff --git a/config.h b/config.h index 315f7e24..86fb2a8f 100644 --- a/config.h +++ b/config.h @@ -247,6 +247,7 @@ struct config { bool dpi_aware; bool gamma_correct; + bool uppercase_regex_insert; struct config_font_list fonts[4]; struct font_size_adjustment font_size_adjustment; diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 7a7fb781..3a057d88 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -231,6 +231,13 @@ empty string to be set, but it must be quoted: *KEY=""*) Default: _no_. +*upppercase-regex-insert* + Boolean. When enabled, inputting an uppercase hint character in + *show-urls-copy* or *regex-copy* mode will insert the selected + text into the prompt in addition to copying it to the clipboard. + + Default: _yes_ + *box-drawings-uses-font-glyphs* Boolean. When disabled, foot generates box/line drawing characters itself. The are several advantages to doing this instead of using diff --git a/foot.ini b/foot.ini index 73fdb7ab..44ed5785 100644 --- a/foot.ini +++ b/foot.ini @@ -40,6 +40,8 @@ # utmp-helper=/usr/lib/utempter/utempter # When utmp backend is ‘libutempter’ (Linux) # utmp-helper=/usr/libexec/ulog-helper # When utmp backend is ‘ulog’ (FreeBSD) +# uppercase-regex-insert=yes + [environment] # name=value diff --git a/tests/test-config.c b/tests/test-config.c index bab57788..8c0805f4 100644 --- a/tests/test-config.c +++ b/tests/test-config.c @@ -491,6 +491,7 @@ test_section_main(void) test_boolean(&ctx, &parse_section_main, "locked-title", &conf.locked_title); test_boolean(&ctx, &parse_section_main, "dpi-aware", &conf.dpi_aware); test_boolean(&ctx, &parse_section_main, "gamma-correct-blending", &conf.gamma_correct); + test_boolean(&ctx, &parse_section_main, "uppercase-regex-insert", &conf.uppercase_regex_insert); test_pt_or_px(&ctx, &parse_section_main, "font-size-adjustment", &conf.font_size_adjustment.pt_or_px); /* TODO: test ‘N%’ values too */ test_pt_or_px(&ctx, &parse_section_main, "line-height", &conf.line_height); diff --git a/url-mode.c b/url-mode.c index 19d95356..44809f5f 100644 --- a/url-mode.c +++ b/url-mode.c @@ -283,7 +283,8 @@ urls_input(struct seat *seat, struct terminal *term, if (match) { // If the last hint character was uppercase, copy and paste - activate_url(seat, term, match, serial, wc == toc32upper(wc)); + bool insert = term->conf->uppercase_regex_insert && wc == toc32upper(wc); + activate_url(seat, term, match, serial, insert); switch (match->action) { case URL_ACTION_COPY: From 1d9ac3f611f1b81983b095a2f96e36dba4d24da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 31 Aug 2025 11:42:56 +0200 Subject: [PATCH 4/9] doc: foot.ini: typo: upppercase -> uppercase --- doc/foot.ini.5.scd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 3a057d88..7550fd13 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -231,7 +231,7 @@ empty string to be set, but it must be quoted: *KEY=""*) Default: _no_. -*upppercase-regex-insert* +*uppercase-regex-insert* Boolean. When enabled, inputting an uppercase hint character in *show-urls-copy* or *regex-copy* mode will insert the selected text into the prompt in addition to copying it to the clipboard. From 65528f455d0d7753da73365fb39b39473a87d8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 9 Sep 2025 17:34:02 +0200 Subject: [PATCH 5/9] meson: utempter del has no argument This fixes an issue where we didn't record a logout record when using the libutempter backend. --- CHANGELOG.md | 3 ++- meson.build | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57144549..4536f6ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,7 +93,8 @@ * Invalid configuration values overriding valid ones in surprising ways. - +* Bug where the libutempter utmp backend did not record logouts + correctly. ### Security ### Contributors diff --git a/meson.build b/meson.build index 0b7bbc17..56f4a31c 100644 --- a/meson.build +++ b/meson.build @@ -53,7 +53,7 @@ if utmp_backend == 'none' elif utmp_backend == 'libutempter' utmp_add = 'add' utmp_del = 'del' - utmp_del_have_argument = true + utmp_del_have_argument = false if utmp_default_helper_path == 'auto' utmp_default_helper_path = join_paths('/usr', get_option('libdir'), 'utempter', 'utempter') endif From efc39097e5a939c4e6f54bf80d24871bfeeaf80b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 9 Sep 2025 17:34:54 +0200 Subject: [PATCH 6/9] term: no need to pass ptmx as stdout to utempter --- terminal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terminal.c b/terminal.c index 2e23f749..421a3e65 100644 --- a/terminal.c +++ b/terminal.c @@ -199,7 +199,7 @@ add_utmp_record(const struct config *conf, struct reaper *reaper, int ptmx) return true; char *const argv[] = {conf->utmp_helper_path, UTMP_ADD, getenv("WAYLAND_DISPLAY"), NULL}; - return spawn(reaper, NULL, argv, ptmx, ptmx, -1, NULL, NULL, NULL) >= 0; + return spawn(reaper, NULL, argv, ptmx, -1, -1, NULL, NULL, NULL) >= 0; #else return true; #endif @@ -223,7 +223,7 @@ del_utmp_record(const struct config *conf, struct reaper *reaper, int ptmx) ; char *const argv[] = {conf->utmp_helper_path, UTMP_DEL, del_argument, NULL}; - return spawn(reaper, NULL, argv, ptmx, ptmx, -1, NULL, NULL, NULL) >= 0; + return spawn(reaper, NULL, argv, ptmx, -1, -1, NULL, NULL, NULL) >= 0; #else return true; #endif From f715f3b55fb094e6ab1fdc18dcf8956227c495c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 12 Sep 2025 10:18:06 +0200 Subject: [PATCH 7/9] changelog: prepare for 1.24.0 --- CHANGELOG.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4536f6ea..7fa3f0ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -* [Unreleased](#unreleased) +* [1.24.0](#1-24-0) * [1.23.1](#1-23-1) * [1.23.0](#1-23-0) * [1.22.3](#1-22-3) @@ -65,7 +65,8 @@ * [1.2.0](#1-2-0) -## Unreleased +## 1.24.0 + ### Added * The `uppercase-regex-insert` option controls whether an uppercase hint @@ -87,8 +88,6 @@ [2156]: https://codeberg.org/dnkl/foot/issues/2156 -### Deprecated -### Removed ### Fixed * Invalid configuration values overriding valid ones in surprising @@ -96,9 +95,11 @@ * Bug where the libutempter utmp backend did not record logouts correctly. -### Security ### Contributors +* Ryan Roden-Corrent +* Tobias Mock + ## 1.23.1 From fa0fd2f50f41d8fc47241dd576be42a2f29d6530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 12 Sep 2025 10:18:33 +0200 Subject: [PATCH 8/9] meson: bump version to 1.24.0 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 56f4a31c..305df13c 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('foot', 'c', - version: '1.23.1', + version: '1.24.0', license: 'MIT', meson_version: '>=0.59.0', default_options: [ From c34f0633075769a2564e10d359feeca604373ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 12 Sep 2025 10:22:21 +0200 Subject: [PATCH 9/9] changelog: add new 'unreleased' section --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fa3f0ea..3144a125 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +* [Unreleased](#unreleased) * [1.24.0](#1-24-0) * [1.23.1](#1-23-1) * [1.23.0](#1-23-0) @@ -65,6 +66,16 @@ * [1.2.0](#1-2-0) +## Unreleased +### Added +### Changed +### Deprecated +### Removed +### Fixed +### Security +### Contributors + + ## 1.24.0 ### Added