aboutsummaryrefslogtreecommitdiff
path: root/src/term/mod.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2019-01-03 21:18:26 +0100
committerChristian Duerr <chrisduerr@users.noreply.github.com>2019-01-05 20:49:39 +0000
commitb6a5ba21a130110c47d9dc43b3d6662051ba22b5 (patch)
tree56077b8dca0b85909557c174292dfa9902cc5b80 /src/term/mod.rs
parentfbefd804c8785caa058d512a95a8e41a21c69435 (diff)
downloadalacritty-b6a5ba21a130110c47d9dc43b3d6662051ba22b5.tar.gz
alacritty-b6a5ba21a130110c47d9dc43b3d6662051ba22b5.zip
Limit number of URL schemes
This limits the number of allowed schemes for the URL launcher, to reduce the number of false-positives. The accepted URL schemes are now: - http - https - mailto - news - file - git - ssh - ftp This fixes #1727.
Diffstat (limited to 'src/term/mod.rs')
-rw-r--r--src/term/mod.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/term/mod.rs b/src/term/mod.rs
index c699adc9..dcde62c8 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -41,6 +41,7 @@ use self::cell::LineLength;
// See https://tools.ietf.org/html/rfc3987#page-13
const URL_SEPARATOR_CHARS: [char; 10] = ['<', '>', '"', ' ', '{', '}', '|', '\\', '^', '`'];
const URL_DENY_END_CHARS: [char; 7] = ['.', ',', ';', ':', '?', '!', '/'];
+const URL_SCHEMES: [&str; 8] = ["http", "https", "mailto", "news", "file", "git", "ssh", "ftp"];
/// A type that can expand a given point to a region
///
@@ -148,7 +149,13 @@ impl Search for Term {
// Check if string is valid url
match Url::parse(&buf) {
- Ok(_) => Some(buf),
+ Ok(url) => {
+ if URL_SCHEMES.contains(&url.scheme()) {
+ Some(buf)
+ } else {
+ None
+ }
+ }
Err(_) => None,
}
}