ropensci / bibtex

bibtex parser for R
https://docs.ropensci.org/bibtex/
35 stars 12 forks source link

Unable to recover after encountering two consecutive TOKEN_LBRACE "{" #42

Closed matthewwiese closed 1 year ago

matthewwiese commented 2 years ago

As part of studying the parser more thoroughly for #40, I discovered what appears to be a critical bug. It occurs in both master and my WIP fixes for the rchk issues (which I have not yet added to the PR)

The bibtex entry that causes this:

encoding = "utf-8"

@String{{ BAZ = "Foo Bar Baz" }

And accessing it in R (I've stored the file in inst/bib locally):

f <- file.path(system.file("bib", "parseError.bib", package = "bibtex"))
bib <- read.bib(f)

The second { correctly causes an error, but the grammar and/or error handling does not appear sufficient in order to recover correctly. Afterwards, I am unable to read any other .bib files - they fail and enter recovery as well.

In addition, a second call to read.bib(f) causes the R session to crash.