diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2023-09-20 13:29:35 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2023-09-21 16:32:57 +0000 |
| commit | 54722369d8ca0c6b90c6d874b0f712e133cd4925 (patch) | |
| tree | 843c2c2df3f7303d1c89e299a89ea6b327fd4cc0 | |
| parent | changelog: crash when xdg token is set, but compositor does not support activation (diff) | |
url-mode: don't strip the file:// prefix from localhost URIs
Before this patch, the file://<host> prefix was stripped from URIs,
when the hostname matched the current host (that is, for "local"
URLs).
Unfortunately, the way this was done caused other parts of the URI to
be stripped as well. For example, the 'query' and 'fragment' parts.
This patch simply removes all special casing of file:// URIs.
Since the URL is passed to a generic opener (i.e. we don't have a
special opener application for file:// URIs), the opener helper must
handle the file:// prefix anyway.
Closes #1474
| -rw-r--r-- | CHANGELOG.md | 3 | ||||
| -rw-r--r-- | url-mode.c | 33 |
2 files changed, 5 insertions, 31 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index fe944218..5e894eed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,9 +74,12 @@ in many cases, triple clicking will still be enough to select the entire row; see the new key binding `select-quote` (mapped to `BTN_LEFT+3` by default) ([#1364][1364]). +* `file://` prefix from URI's are no longer stripped when + opened/activated ([#1474][1474]). [1391]: https://codeberg.org/dnkl/foot/issues/1391 [1448]: https://codeberg.org/dnkl/foot/pulls/1448 +[1474]: https://codeberg.org/dnkl/foot/pulls/1474 ### Deprecated @@ -128,46 +128,17 @@ static void activate_url(struct seat *seat, struct terminal *term, const struct url *url, uint32_t serial) { - char *url_string = NULL; - - char *scheme, *host, *path; - if (uri_parse(url->url, strlen(url->url), &scheme, NULL, NULL, - &host, NULL, &path, NULL, NULL)) - { - if (strcmp(scheme, "file") == 0 && hostname_is_localhost(host)) { - /* - * This is a file in *this* computer. Pass only the - * filename to the URL-launcher. - * - * I.e. strip the ‘file://user@host/’ prefix. - */ - url_string = path; - } else - free(path); - - free(scheme); - free(host); - } - - if (url_string == NULL) - url_string = xstrdup(url->url); - switch (url->action) { case URL_ACTION_COPY: - if (text_to_clipboard(seat, term, url_string, seat->kbd.serial)) { - /* Now owned by our clipboard “manager” */ - url_string = NULL; - } + text_to_clipboard(seat, term, xstrdup(url->url), seat->kbd.serial); break; case URL_ACTION_LAUNCH: case URL_ACTION_PERSISTENT: { - spawn_url_launcher(seat, term, url_string, serial); + spawn_url_launcher(seat, term, url->url, serial); break; } } - - free(url_string); } void |
