zepinglee / citeproc-lua

A Lua implementation of the Citation Style Language (CSL)
MIT License
62 stars 7 forks source link

underscore in .bib file keys causes halt #22

Closed Denubis closed 1 year ago

Denubis commented 1 year ago

In a very long .bib, my colleague has collected many items. One item had two keys in it:

  HAL_ID={hal-03186401},
  HAL_VERSION={v1},

When I run this in texlive 2022 (on overleaf, but it's been reproduced outside), it fails to compile with a timeout.

When I remove those two keys, it runs.

Here is a MWE:

\documentclass{article}

\title{citeproc-lua-test}

\begin{filecontents}[overwrite]{\jobname.bib}

@incollection{haltest,
  TITLE={{A tale of two funerary traditons: the predynastic cemetery at Kom el-Khilgan (eastern delta)}},
  AUTHOR={Buchez, N. and Midant-Reynes, B.},
  URL={https://hal.archives-ouvertes.fr/hal-03186401},
  BOOKTITLE={{Egypt and its Origins 3. Proceedings of the Third International Conference ''Origin of the State. Predynastic and Early Dynastic Egypt'', London, 27th July-1st August 2008}},
  EDITOR={Ren{\'e}e F. Friedman and Peter N. Fiske},
  PUBLISHER={{Peeters}},
  SERIES={Orientalia Lovaniensia Analecta},
  VOLUME={205},
  PAGES={831--858},
  YEAR={2011},
  HAL_ID={hal-03186401},
  HAL_VERSION={v1},
}

\end{filecontents}

\usepackage{citation-style-language}
\cslsetup{style = apa}
\addbibresource{\jobname.bib}

\begin{document}

\cite{haltest}
\printbibliography

\end{document}
zepinglee commented 1 year ago

Thanks for you feedback. I think it's the same issue as #18. The infinite loop error should be fixed in 2c747da.

However the provided .bib example is still not fully correctly parsed. I'll look into it.

[
    {
        "citation-key": "haltest",
        "id": "haltest",
        "type": "chapter"
    }
]
zepinglee commented 1 year ago

@Denubis I've rewritten the BibTeX parser with lpeg (c720941) and the provided example parses correctly. See https://github.com/zepinglee/citeproc-lua/blob/52d6e3bd7e0574d2f54e0fcf0a1ccee86f41e532/test/bibtex_test.lua#L664-L715.