aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2025-02-09 08:11:27 +0000
committerDaniel Eklöf <daniel@ekloef.se>2025-02-10 07:06:08 +0000
commit4e5ad6e013666e4724b4de4273ac445adceb0865 (patch)
treed3b93bc03fbcc6d8217a60d47ac39c6e2a5917c7
parentconfig: regex: fix invalid free (diff)
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).
-rw-r--r--url-mode.c3
1 files changed, 2 insertions, 1 deletions
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};
}