diff --git a/src/lexer.rs b/src/lexer.rs index e8aa1dd..858a197 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -40,12 +40,7 @@ impl<'a> Iterator for Lexer<'a> { impl<'a> Lexer<'a> { pub fn new(file: &'a Arc) -> Lexer<'a> { Lexer { - buf: file - .source() - .trim_start_matches("\u{ef}\u{bb}\u{bf}") - .trim_start_matches("\u{feff}") - .chars() - .peekable(), + buf: file.source().chars().peekable(), pos: 0, file, } diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 58630c7..f09eaac 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -96,6 +96,9 @@ impl<'a> Parser<'a> { pub fn parse(&mut self) -> SassResult> { let mut stmts = Vec::new(); + // Allow a byte-order mark at the beginning of the document. + self.consume_char_if_exists('\u{feff}'); + self.whitespace(); stmts.append(&mut self.load_modules()?); diff --git a/tests/misc.rs b/tests/misc.rs index 1b66ac7..37d0f37 100644 --- a/tests/misc.rs +++ b/tests/misc.rs @@ -101,8 +101,3 @@ test!( "\u{feff}a {\n color: red\n}\n", "a {\n color: red;\n}\n" ); -test!( - file_begins_with_bom, - "\u{ef}\u{bb}\u{bf}a {\n color: red\n}\n", - "a {\n color: red;\n}\n" -);