Fix panic when progid is the last token by removing unwrap (#39)

* Fix panic when progid by removing unwrap

* Incorporate PR feedback
This commit is contained in:
Midas Lambrichts 2020-08-25 01:35:55 +02:00 committed by GitHub
parent c0c8de6eb9
commit 8e060950d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -64,7 +64,12 @@ impl<'a> Parser<'a> {
pub(super) fn parse_progid(&mut self) -> SassResult<String> { pub(super) fn parse_progid(&mut self) -> SassResult<String> {
let mut string = String::new(); let mut string = String::new();
let mut span = self.toks.peek().unwrap().pos(); let mut span = match self.toks.peek() {
Some(token) => token.pos(),
None => {
return Err(("expected \"(\".", self.span_before).into());
}
};
while let Some(tok) = self.toks.next() { while let Some(tok) = self.toks.next() {
span = span.merge(tok.pos()); span = span.merge(tok.pos());
match tok.kind { match tok.kind {

View File

@ -202,3 +202,7 @@ test!(
"a {\n color: PrOgId:foo(fff);\n}\n", "a {\n color: PrOgId:foo(fff);\n}\n",
"a {\n color: progid:foo(fff);\n}\n" "a {\n color: progid:foo(fff);\n}\n"
); );
error!(
progid_nothing_after,
"a { color: progid:", "Error: expected \"(\"."
);