Skip to content

Commit 5290e58

Browse files
committed
Bug fix repair: UTF8-BOM file supported
1 parent dc0e51a commit 5290e58

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

oneport/src/config.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ async fn find_config(file: Option<String>) -> Option<String> {
6969
Ok(v) => v,
7070
_ => continue,
7171
};
72-
let config = String::from_utf8(config).unwrap_or_default();
72+
let config = if config[..3] == vec![0xEF, 0xBB, 0xBF] {
73+
&config[3..]
74+
} else {
75+
&config
76+
};
77+
let config = String::from_utf8_lossy(config).to_string();
7378
return Some(config);
7479
}
7580
None

0 commit comments

Comments
 (0)