inukshuk / bibtex-ruby

A BibTeX library, parser, and converter for Ruby.
http://inukshuk.github.com/bibtex-ruby
GNU General Public License v3.0
156 stars 31 forks source link

Program crash when parsing large BibTex strings #113

Closed jheer closed 8 years ago

jheer commented 8 years ago

I'm using jekyll-scholar with a large bibtex file and ran into an error that I tracked down into bibtex-ruby.

The offending line is lib/bibtex/utilities.rb#L33. If the string input is so long as to be an invalid file name, the File.exists? call raises an error. A length check to ensure the string is not too long seems to suffice to fix the issue. That said, having the method change its behavior based on the string content (rather than an option) seems rather dangerous in general.

inukshuk commented 8 years ago

Thanks! I added an additional check; the method is for convenience since you ought to use open/parse directly depending on your input. Having said that, I changed the jekyll-scholar code in question to do just that.

jheer commented 8 years ago

Thanks!