Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add confirmation prompts for url schemes #302

Merged
merged 3 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ---------------------------------
Expand Down
12 changes: 12 additions & 0 deletions default-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ---------------------------------
Expand Down
9 changes: 9 additions & 0 deletions display/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down