aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-05-20 18:45:01 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-05-22 12:50:47 +0000
commit121ea39942ce8756f4f6c9e45e5c8b60ad819d15 (patch)
tree887b7fa3249337fb8aebfbec2df231656120c16a
parentconfig: add url.protocols (diff)
config: url.protocols: make it comma separated, for consistency
-rw-r--r--config.c20
-rw-r--r--doc/foot.ini.5.scd9
-rw-r--r--foot.ini2
3 files changed, 21 insertions, 10 deletions
diff --git a/config.c b/config.c
index 08446e7d..d0b36129 100644
--- a/config.c
+++ b/config.c
@@ -1012,10 +1012,20 @@ parse_section_url(const char *key, const char *value, struct config *conf,
char *copy = xstrdup(value);
- for (char *prot = strtok(copy, " ");
+ for (char *prot = strtok(copy, ",");
prot != NULL;
- prot = strtok(NULL, " "))
+ prot = strtok(NULL, ","))
{
+
+ /* Strip leading whitespace */
+ while (isspace(*prot))
+ prot++;
+
+ /* Strip trailing whitespace */
+ size_t len = strlen(prot);
+ while (len > 0 && isspace(prot[len - 1]))
+ prot[--len] = '\0';
+
size_t chars = mbstowcs(NULL, prot, 0);
if (chars == (size_t)-1) {
LOG_AND_NOTIFY_ERRNO(
@@ -1034,9 +1044,9 @@ parse_section_url(const char *key, const char *value, struct config *conf,
mbstowcs(conf->url.protocols[idx], prot, chars + 1);
wcscpy(&conf->url.protocols[idx][chars], L"://");
- size_t len = chars + 3; /* Include the "://" */
- if (len > conf->url.max_prot_len)
- conf->url.max_prot_len = len;
+ chars += 3; /* Include the "://" */
+ if (chars > conf->url.max_prot_len)
+ conf->url.max_prot_len = chars;
}
free(copy);
diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd
index f224c957..8ee3b581 100644
--- a/doc/foot.ini.5.scd
+++ b/doc/foot.ini.5.scd
@@ -324,10 +324,11 @@ in this order:
jump labels. Default: _sadfjklewcmpgh_.
*protocols*
- List of protocols (schemes) that should be recognized in URL
- mode. Note that only auto-detected URLs are affected by this
- option. OSC-8 URLs are always enabled, regardless of
- protocol. Default: _http https ftp ftps file gemini gopher_.
+ Comma separated list of protocols (schemes) that should be
+ recognized in URL mode. Note that only auto-detected URLs are
+ affected by this option. OSC-8 URLs are always enabled, regardless
+ of protocol. Default: _http, https, ftp, ftps, file, gemini,
+ gopher_.
# SECTION: cursor
diff --git a/foot.ini b/foot.ini
index c4f786a9..12bb0aa7 100644
--- a/foot.ini
+++ b/foot.ini
@@ -45,7 +45,7 @@
# launch=xdg-open ${url}
# label-letters=sadfjklewcmpgh
# osc8-underline=url-mode
-# protocols = http https ftp ftps file gemini gopher
+# protocols = http, https, ftp, ftps, file, gemini, gopher
[cursor]
# style=block