mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
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.
This commit is contained in:
parent
fbefd804c8
commit
b6a5ba21a1
2 changed files with 9 additions and 1 deletions
|
@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Windows configuration location has been moved from %USERPROFILE%\alacritty.yml
|
- Windows configuration location has been moved from %USERPROFILE%\alacritty.yml
|
||||||
to %APPDATA%\alacritty\alacritty.yml
|
to %APPDATA%\alacritty\alacritty.yml
|
||||||
- Windows default shell is now PowerShell instead of cmd
|
- Windows default shell is now PowerShell instead of cmd
|
||||||
|
- URL schemes have been limited to http, https, mailto, news, file, git, ssh and ftp
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ use self::cell::LineLength;
|
||||||
// See https://tools.ietf.org/html/rfc3987#page-13
|
// See https://tools.ietf.org/html/rfc3987#page-13
|
||||||
const URL_SEPARATOR_CHARS: [char; 10] = ['<', '>', '"', ' ', '{', '}', '|', '\\', '^', '`'];
|
const URL_SEPARATOR_CHARS: [char; 10] = ['<', '>', '"', ' ', '{', '}', '|', '\\', '^', '`'];
|
||||||
const URL_DENY_END_CHARS: [char; 7] = ['.', ',', ';', ':', '?', '!', '/'];
|
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
|
/// 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
|
// Check if string is valid url
|
||||||
match Url::parse(&buf) {
|
match Url::parse(&buf) {
|
||||||
Ok(_) => Some(buf),
|
Ok(url) => {
|
||||||
|
if URL_SCHEMES.contains(&url.scheme()) {
|
||||||
|
Some(buf)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
Err(_) => None,
|
Err(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue