aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhairul Azhar Kasmiran <kazarmy@gmail.com>2019-05-29 00:29:42 +0800
committerChristian Duerr <chrisduerr@users.noreply.github.com>2019-05-28 16:29:42 +0000
commitdea7a0890a724c50bc5767039f45a2e3d071ee1c (patch)
treed1f5404df9d1657467e55c9b7249b900d8ee00ab
parentbc174a5ec3de6a32adaecc3a4be8851c6605688d (diff)
downloadr-alacritty-dea7a0890a724c50bc5767039f45a2e3d071ee1c.tar.gz
r-alacritty-dea7a0890a724c50bc5767039f45a2e3d071ee1c.tar.bz2
r-alacritty-dea7a0890a724c50bc5767039f45a2e3d071ee1c.zip
Skip UTF-8 BOM when reading config file
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty/src/config.rs5
2 files changed, 6 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1e0d9fdd..c98b0c7b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
- Text getting recognized as URLs without slashes separating the scheme
- URL parser dropping trailing slashes from valid URLs
+- UTF-8 BOM skipped when reading config file
### Removed
diff --git a/alacritty/src/config.rs b/alacritty/src/config.rs
index ea487ecd..6d185fe7 100644
--- a/alacritty/src/config.rs
+++ b/alacritty/src/config.rs
@@ -179,6 +179,11 @@ fn read_config(path: &PathBuf) -> Result<Config> {
let mut contents = String::new();
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
if contents.is_empty() {
return Ok(Config::default());