diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2022-08-30 15:48:04 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2022-08-31 17:16:19 +0000 |
| commit | 5706141d0a5250af761f29989dad8161ed1cf2b6 (patch) | |
| tree | 8e3dac0c8a11ff753806f68eb5629a0772287678 | |
| parent | changelog: crash when resizing window, or scrolling (diff) | |
url-mode: connect osc-8 links only when both ID and URI matches
Before this, two OSC-8 links with a matching ID would be connected
even if their URIs weren’t the same. This is against the spec:
The same id is only used for connecting character cells whose URIs
is also the same. Character cells pointing to different URIs should
never be underlined together when hovering over.
https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#hover-underlining-and-the-id-parameter
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | url-mode.c | 16 |
2 files changed, 12 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 22267556..fe6e7fcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,8 @@ selected when they should not. * Crash when either resizing the terminal window, or scrolling in the scrollback history ([#1074][1074]) +* OSC-8 URLs with matching IDs, but mismatching URIs being incorrectly + connected. [1074]: https://codeberg.org/dnkl/foot/pulls/1074 @@ -677,18 +677,23 @@ urls_assign_key_combos(const struct config *conf, url_list_t *urls) if (count == 0) return; - uint64_t seen_ids[count]; char32_t *combos[count]; generate_key_combos(conf, count, combos); size_t combo_idx = 0; - size_t id_idx = 0; tll_foreach(*urls, it) { bool id_already_seen = false; - for (size_t i = 0; i < id_idx; i++) { - if (it->item.id == seen_ids[i]) { + /* Look for already processed URLs where both the URI and the + * ID matches */ + tll_foreach(*urls, it2) { + if (&it->item == &it2->item) + break; + + if (it->item.id == it2->item.id && + strcmp(it->item.url, it2->item.url) == 0) + { id_already_seen = true; break; } @@ -696,7 +701,6 @@ urls_assign_key_combos(const struct config *conf, url_list_t *urls) if (id_already_seen) continue; - seen_ids[id_idx++] = it->item.id; /* * Scan previous URLs, and check if *this* URL matches any of @@ -730,7 +734,7 @@ urls_assign_key_combos(const struct config *conf, url_list_t *urls) char *key = ac32tombs(it->item.key); xassert(key != NULL); - LOG_DBG("URL: %s (%s)", it->item.url, key); + LOG_DBG("URL: %s (key=%s, id=%"PRIu64")", it->item.url, key, it->item.id); free(key); } #endif |
