1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-12-04 14:46:29 -05:00

add confirmation prompts for url schemes (#302)

* add confirmation prompts for url schemes

This commit adds a confirmation prompt before following urls with
with certain schemes.
Wether or not a scheme requires confirmation can be configured in the
new `[url-promps]` section.

* Use other instead of default

* Use other instead of default

Co-authored-by: makeworld <makeworld@protonmail.com>
This commit is contained in:
Emily 2022-04-26 03:01:08 +02:00 committed by GitHub
parent 32b2182267
commit 00541a435d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 0 deletions

View File

@ -257,6 +257,7 @@ func Init() error {
viper.SetDefault("keybindings.shift_numbers", "")
viper.SetDefault("keybindings.bind_url_handler_open", "Ctrl-U")
viper.SetDefault("url-handlers.other", "default")
viper.SetDefault("url-prompts.other", false)
viper.SetDefault("cache.max_size", 0)
viper.SetDefault("cache.max_pages", 20)
viper.SetDefault("cache.timeout", 1800)

View File

@ -218,6 +218,18 @@ underline = true
# application on your computer for opening this kind of URI.
other = 'default'
[url-prompts]
# Specify whether a confirmation prompt should be shown before following URL schemes.
# The special key 'other' matches all schemes that don't match any other key.
#
# Example: prompt on every non-gemini URL
# other = true
# gemini = false
#
# Example: only prompt on HTTP(S)
# other = false
# http = true
# https = true
# [[mediatype-handlers]] section
# ---------------------------------

View File

@ -215,6 +215,18 @@ underline = true
# application on your computer for opening this kind of URI.
other = 'default'
[url-prompts]
# Specify whether a confirmation prompt should be shown before following URL schemes.
# The special key 'other' matches all schemes that don't match any other key.
#
# Example: prompt on every non-gemini URL
# other = true
# gemini = false
#
# Example: only prompt on HTTP(S)
# other = false
# http = true
# https = true
# [[mediatype-handlers]] section
# ---------------------------------

View File

@ -252,6 +252,15 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) {
return ret("", false)
}
// check if a prompt is needed to handle this url
prompt := viper.GetBool("url-prompts.other")
if viper.IsSet("url-prompts." + parsed.Scheme) {
prompt = viper.GetBool("url-prompts." + parsed.Scheme)
}
if prompt && !(YesNo("Follow URL?\n" + u)) {
return ret("", false)
}
proxy := strings.TrimSpace(viper.GetString("proxies." + parsed.Scheme))
usingProxy := false