mirror of
https://github.com/alacritty/alacritty.git
synced 2025-09-04 22:43:53 -04:00
Skip UTF-8 BOM when reading config file
This commit is contained in:
parent
bc174a5ec3
commit
dea7a0890a
2 changed files with 6 additions and 0 deletions
|
@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- On macOS, automatic graphics switching has been enabled again
|
- On macOS, automatic graphics switching has been enabled again
|
||||||
- Text getting recognized as URLs without slashes separating the scheme
|
- Text getting recognized as URLs without slashes separating the scheme
|
||||||
- URL parser dropping trailing slashes from valid URLs
|
- URL parser dropping trailing slashes from valid URLs
|
||||||
|
- UTF-8 BOM skipped when reading config file
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|
|
@ -179,6 +179,11 @@ fn read_config(path: &PathBuf) -> Result<Config> {
|
||||||
let mut contents = String::new();
|
let mut contents = String::new();
|
||||||
File::open(path)?.read_to_string(&mut contents)?;
|
File::open(path)?.read_to_string(&mut contents)?;
|
||||||
|
|
||||||
|
// Remove UTF-8 BOM
|
||||||
|
if contents.chars().nth(0) == Some('\u{FEFF}') {
|
||||||
|
contents = contents.split_off(3);
|
||||||
|
}
|
||||||
|
|
||||||
// Prevent parsing error with empty string
|
// Prevent parsing error with empty string
|
||||||
if contents.is_empty() {
|
if contents.is_empty() {
|
||||||
return Ok(Config::default());
|
return Ok(Config::default());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue