mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-19 05:33:44 -04:00
url-mode: activate_url(): ensure ‘scheme’, ‘host’ and ‘path’ are free:d
uri_parse() may succeed. But if the scheme isn’t “file”, or if the hostname isn’t localhost, then we failed to free ‘scheme’, ‘host’ and ‘path’.
This commit is contained in:
parent
fb9e9513a5
commit
a99f9c9341
1 changed files with 15 additions and 11 deletions
26
url-mode.c
26
url-mode.c
|
|
@ -42,20 +42,24 @@ activate_url(struct seat *seat, struct terminal *term, const struct url *url)
|
||||||
|
|
||||||
char *scheme, *host, *path;
|
char *scheme, *host, *path;
|
||||||
if (uri_parse(url->url, strlen(url->url), &scheme, NULL, NULL,
|
if (uri_parse(url->url, strlen(url->url), &scheme, NULL, NULL,
|
||||||
&host, NULL, &path, NULL, NULL) &&
|
&host, NULL, &path, NULL, NULL))
|
||||||
strcmp(scheme, "file") == 0 &&
|
|
||||||
hostname_is_localhost(host))
|
|
||||||
{
|
{
|
||||||
/*
|
if (strcmp(scheme, "file") == 0 && hostname_is_localhost(host)) {
|
||||||
* This is a file in *this* computer. Pass only the
|
/*
|
||||||
* filename to the URL-launcher.
|
* This is a file in *this* computer. Pass only the
|
||||||
*
|
* filename to the URL-launcher.
|
||||||
* I.e. strip the ‘file://user@host/’ prefix.
|
*
|
||||||
*/
|
* I.e. strip the ‘file://user@host/’ prefix.
|
||||||
url_string = path;
|
*/
|
||||||
|
url_string = path;
|
||||||
|
} else
|
||||||
|
free(path);
|
||||||
|
|
||||||
free(scheme);
|
free(scheme);
|
||||||
free(host);
|
free(host);
|
||||||
} else
|
}
|
||||||
|
|
||||||
|
if (url_string == NULL)
|
||||||
url_string = xstrdup(url->url);
|
url_string = xstrdup(url->url);
|
||||||
|
|
||||||
switch (url->action) {
|
switch (url->action) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue