From 4e5ad6e013666e4724b4de4273ac445adceb0865 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 9 Feb 2025 09:11:27 +0100 Subject: [PATCH] Fix URL detection regression on lines with NUL bytes Commit 859b4c89 (url-mode: wip: more work on regex matching, 2025-01-30) regressed URL detection in weechat. Some of the URLs still work but others don't. This is because regexec() stops at the first NUL, thus skipping the rest of the line. weechat seems create NUL cells between their UI widgets. Work around this by replacing NUL with space. This is probably correct because selecting and copying those cells also translates to space (not sure where in the code). --- url-mode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/url-mode.c b/url-mode.c index 0101de19..6fd7f03a 100644 --- a/url-mode.c +++ b/url-mode.c @@ -368,7 +368,8 @@ regex_detected(const struct terminal *term, enum url_action action, vline->sz = new_size; } - vline->utf8[vline->len + j] = buf[j]; + vline->utf8[vline->len + j] = + (buf[j] == '\0') ? ' ' : buf[j]; vline->map[vline->len + j] = (struct coord){c, term->grid->view + r}; }