aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.c85
-rw-r--r--doc/foot.ini.5.scd2
-rw-r--r--foot.ini2
3 files changed, 45 insertions, 44 deletions
diff --git a/config.c b/config.c
index 824a4ded..618ee116 100644
--- a/config.c
+++ b/config.c
@@ -106,6 +106,47 @@ static const uint32_t default_sixel_colors[16] = {
0xffcccccc,
};
+static const char *const default_url_regex_string =
+ "("
+ "("
+ "(https?://|mailto:|ftp://|file:|ssh:|ssh://|git://|tel:|magnet:|ipfs://|ipns://|gemini://|gopher://|news:)"
+ "|"
+ "www\\."
+ ")"
+ "("
+ /* Safe + reserved + some unsafe characters parenthesis and double quotes omitted (we only allow them when balanced) */
+ "[0-9a-zA-Z:/?#@!$&*+,;=.~_%^'\\-]+"
+ "|"
+ /* Balanced "(...)". Content is same as above, plus all _other_ characters we require to be balanced */
+ "\\([]\\[\"0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\\-]+\\)"
+ "|"
+ /* Balanced "[...]". Content is same as above, plus all _other_ characters we require to be balanced */
+ "\\[[\\(\\)\"0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\\-]+\\]"
+ "|"
+ /* Balanced '"..."'. Content is same as above, plus all _other_ characters we require to be balanced */
+ "\"[]\\[\\(\\)0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\\-]+\""
+ "|"
+ /* Balanced "'...'". Content is same as above, plus all _other_ characters we require to be balanced */
+ "'[]\\[\\(\\)0-9a-zA-Z:/?#@!$&*+,;=.~_%^\\-]+'"
+ ")+"
+ "("
+ /* Same as above, except :?!,;.' are excluded */
+ "[0-9a-zA-Z/#@$&*+=~_%^\\-]"
+ "|"
+ /* Balanced "(...)". Content is same as above, plus all _other_ characters we require to be balanced */
+ "\\([]\\[\"0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\\-]+\\)"
+ "|"
+ /* Balanced "[...]". Content is same as above, plus all _other_ characters we require to be balanced */
+ "\\[[\\(\\)\"0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\\-]+\\]"
+ "|"
+ /* Balanced '"..."'. Content is same as above, plus all _other_ characters we require to be balanced */
+ "\"[]\\[\\(\\)0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\\-]+\""
+ "|"
+ /* Balanced "'...'". Content is same as above, plus all _other_ characters we require to be balanced */
+ "'[]\\[\\(\\)0-9a-zA-Z:/?#@!$&*+,;=.~_%^\\-]+'"
+ ")"
+ ")";
+
static const char *const binding_action_map[] = {
[BIND_ACTION_NONE] = NULL,
[BIND_ACTION_NOOP] = "noop",
@@ -3654,50 +3695,10 @@ config_load(struct config *conf, const char *conf_path,
tokenize_cmdline("xdg-open ${url}", &conf->url.launch.argv.args);
{
- const char *url_regex_string =
- "("
- "("
- "(https?://|mailto:|ftp://|file:|ssh:|ssh://|git://|tel:|magnet:|ipfs://|ipns://|gemini://|gopher://|news:)"
- "|"
- "www\\."
- ")"
- "("
- /* Safe + reserved + some unsafe characters parenthesis and double quotes omitted (we only allow them when balanced) */
- "[0-9a-zA-Z:/?#@!$&*+,;=.~_%^\\-]+"
- "|"
- /* Balanced "(...)". Content is same as above, plus all _other_ characters we require to be balanced */
- "\\([]\\[\"0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\\-]*\\)"
- "|"
- /* Balanced "[...]". Content is same as above, plus all _other_ characters we require to be balanced */
- "\\[[\\(\\)\"0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\\-]*\\]"
- "|"
- /* Balanced '"..."'. Content is same as above, plus all _other_ characters we require to be balanced */
- "\"[]\\[\\(\\)0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\\-]*\""
- "|"
- /* Balanced "'...'". Content is same as above, plus all _other_ characters we require to be balanced */
- "'[]\\[\\(\\)0-9a-zA-Z:/?#@!$&*+,;=.~_%^\\-]*'"
- ")+"
- "("
- /* Same as above, except :?!,;. are excluded */
- "[0-9a-zA-Z/#@$&*+=~_%^\\-]"
- "|"
- /* Balanced "(...)". Content is same as above, plus all _other_ characters we require to be balanced */
- "\\([]\\[\"0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\\-]*\\)"
- "|"
- /* Balanced "[...]". Content is same as above, plus all _other_ characters we require to be balanced */
- "\\[[\\(\\)\"0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\\-]*\\]"
- "|"
- /* Balanced '"..."'. Content is same as above, plus all _other_ characters we require to be balanced */
- "\"[]\\[\\(\\)0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\\-]*\""
- "|"
- /* Balanced "'...'". Content is same as above, plus all _other_ characters we require to be balanced */
- "'[]\\[\\(\\)0-9a-zA-Z:/?#@!$&*+,;=.~_%^\\-]*'"
- ")"
- ")";
- int r = regcomp(&conf->url.preg, url_regex_string, REG_EXTENDED);
+ int r = regcomp(&conf->url.preg, default_url_regex_string, REG_EXTENDED);
xassert(r == 0);
- conf->url.regex = xstrdup(url_regex_string);
+ conf->url.regex = xstrdup(default_url_regex_string);
xassert(conf->url.preg.re_nsub >= 1);
}
diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd
index ce733b77..c7fe22c7 100644
--- a/doc/foot.ini.5.scd
+++ b/doc/foot.ini.5.scd
@@ -908,7 +908,7 @@ section.
whole regex match to be used as an URL, surround all of it with
parenthesis: *(regex-pattern)*.
- Default: _(((https?://|mailto:|ftp://|file:|ssh:|ssh://|git://|tel:|magnet:|ipfs://|ipns://|gemini://|gopher://|news:)|www\.)([0-9a-zA-Z:/?#@!$&\*+,;=.~\_%^\-]+|\([]\["0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]\*\)|\[[\(\)"0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]\*\]|"[]\[\(\)0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]\*"|'[]\[\(\)0-9a-zA-Z:/?#@!$&\*+,;=.~\_%^\-]\*')+([0-9a-zA-Z/#@$&\*+=~\_%^\-]|\([]\["0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]\*\)|\[[\(\)"0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]\*\]|"[]\[\(\)0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]\*"|'[]\[\(\)0-9a-zA-Z:/?#@!$&\*+,;=.~\_%^\-]\*'))_
+ Default: _(((https?://|mailto:|ftp://|file:|ssh:|ssh://|git://|tel:|magnet:|ipfs://|ipns://|gemini://|gopher://|news:)|www\.)([0-9a-zA-Z:/?#@!$&\*+,;=.~\_%^'\-]+|\([]\["0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]+\)|\[[\(\)"0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]+\]|"[]\[\(\)0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]+"|'[]\[\(\)0-9a-zA-Z:/?#@!$&\*+,;=.~\_%^\-]+')+([0-9a-zA-Z/#@$&\*+=~\_%^\-]|\([]\["0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]+\)|\[[\(\)"0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]+\]|"[]\[\(\)0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]+"|'[]\[\(\)0-9a-zA-Z:/?#@!$&\*+,;=.~\_%^\-]+'))_
# SECTION: regex
diff --git a/foot.ini b/foot.ini
index b733c6a4..6469af78 100644
--- a/foot.ini
+++ b/foot.ini
@@ -79,7 +79,7 @@
# label-letters=sadfjklewcmpgh
# style=dotted (none|single|double|curly|dotted|dashed)
# osc8-underline=url-mode
-# regex=(((https?://|mailto:|ftp://|file:|ssh:|ssh://|git://|tel:|magnet:|ipfs://|ipns://|gemini://|gopher://|news:)|www\.)([0-9a-zA-Z:/?#@!$&*+,;=.~_%^\-]+|\([]\["0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]*\)|\[[\(\)"0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]*\]|"[]\[\(\)0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]*"|'[]\[\(\)0-9a-zA-Z:/?#@!$&*+,;=.~_%^\-]*')+([0-9a-zA-Z/#@$&*+=~_%^\-]|\([]\["0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]*\)|\[[\(\)"0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]*\]|"[]\[\(\)0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]*"|'[]\[\(\)0-9a-zA-Z:/?#@!$&*+,;=.~_%^\-]*'))
+# regex=(((https?://|mailto:|ftp://|file:|ssh:|ssh://|git://|tel:|magnet:|ipfs://|ipns://|gemini://|gopher://|news:)|www\.)([0-9a-zA-Z:/?#@!$&*+,;=.~_%^'\-]+|\([]\["0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]+\)|\[[\(\)"0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]+\]|"[]\[\(\)0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]+"|'[]\[\(\)0-9a-zA-Z:/?#@!$&*+,;=.~_%^\-]+')+([0-9a-zA-Z/#@$&*+=~_%^\-]|\([]\["0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]+\)|\[[\(\)"0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]+\]|"[]\[\(\)0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]+"|'[]\[\(\)0-9a-zA-Z:/?#@!$&*+,;=.~_%^\-]+'))
# You can define your own regex's, by adding a section called
# 'regex:<ID>' with a 'regex' and 'launch' key. These can then be tied