Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoformat corrupts .bib file that contains # #7483

Closed
lavalade opened this issue Mar 2, 2021 · 3 comments
Closed

Autoformat corrupts .bib file that contains # #7483

lavalade opened this issue Mar 2, 2021 · 3 comments

Comments

@lavalade
Copy link

lavalade commented Mar 2, 2021

The bug was discovered on :
JabRef 5.2--2020-12-24--6a2a512
Mac OS X 10.15.7 x86_64
Java 15.0.1

And it is reproductible on the latest development version :
JabRef 5.3--2021-03-01--cfb504c
Mac OS X 10.15.7 x86_64
Java 15.0.2
JavaFX 15.0.1+1

When open a *.bib file where some comment fields contains two #, the autoformat corrupt the *.bib file by replacing the first # by } # and the second # by # {.
I found this bug on my main database (22000+ lines) and I reproduced it on a minimum file with only one entry, see below.
To reproduce this bug :

  1. Launch JabRef
  2. Open the *.bib
  3. Wait circa 15 secondes
  4. The autoformat has been automatically executed (but *.bib file has not been overwritten yet), a * appears before the file name in the tab title
  5. Save the file
  6. Quit JabRef
  7. When reopening the file, error message appears (on my main database with many entries and 22000+ lines, but not with the minify example given here).

Below the original error message after my main database has been corrupted :

Screenshot 2021-03-02 at 22 18 22

This issues seems closes to two others that imply # too :

But it seems sufficiently different to me, hence I opened this new issue.

Example of *.bib with # corrupted

The comment field contains two URL both containing one # : corruption.

Original *.bib file

@Article{ArevaloJr_2009_EPSL278_KUratioSilicateEarth,
  Title                    = {The K/U ratio of the silicate Earth: Insights into mantle composition, structure and thermal evolution},
  Author                   = {Arevalo Jr., Ricardo and McDonough, William F. and Luong, Mario},
  Journal                  = {Earth Planet. Sci. Lett.},
  Year                     = {2009},
  Number                   = {3–4},
  Pages                    = {361 - 369},
  Volume                   = {278},

  Comment                  = {Téléchargé suite à la lecture de :
https://en.wikipedia.org/wiki/Thorium#Formation
et de :
https://en.wikipedia.org/wiki/Thorium#On_Earth
},
  Doi                      = {http://dx.doi.org/10.1016/j.epsl.2008.12.023},
}

Corrupted *.bib after autoformat

% Encoding: UTF-8

@Article{ArevaloJr_2009_EPSL278_KUratioSilicateEarth,
  author  = {Arevalo Jr., Ricardo and McDonough, William F. and Luong, Mario},
  journal = {Earth Planet. Sci. Lett.},
  title   = {The K/U ratio of the silicate Earth: Insights into mantle composition, structure and thermal evolution},
  year    = {2009},
  number  = {3–4},
  pages   = {361 - 369},
  volume  = {278},
  comment = {Téléchargé suite à la lecture de :
https://en.wikipedia.org/wiki/Thorium} # Formation
	
	et de :
	
	https://en.wikipedia.org/wiki/Thorium #{On_Earth},
  doi     = {http://dx.doi.org/10.1016/j.epsl.2008.12.023},
}

@Comment{jabref-meta: databaseType:bibtex;}

Example of *.bib with # not corrupted

The comment field contains only one URL containing one # : no corruption.

Original *.bib file

@Article{ArevaloJr_2009_EPSL278_KUratioSilicateEarth,
  Title                    = {The K/U ratio of the silicate Earth: Insights into mantle composition, structure and thermal evolution},
  Author                   = {Arevalo Jr., Ricardo and McDonough, William F. and Luong, Mario},
  Journal                  = {Earth Planet. Sci. Lett.},
  Year                     = {2009},
  Number                   = {3–4},
  Pages                    = {361 - 369},
  Volume                   = {278},

  Comment                  = {Téléchargé suite à la lecture de :
https://en.wikipedia.org/wiki/Thorium#Formation
},
  Doi                      = {http://dx.doi.org/10.1016/j.epsl.2008.12.023},
}

Not corrupted *.bib after autoformat

% Encoding: UTF-8

@Article{ArevaloJr_2009_EPSL278_KUratioSilicateEarth,
  author  = {Arevalo Jr., Ricardo and McDonough, William F. and Luong, Mario},
  journal = {Earth Planet. Sci. Lett.},
  title   = {The K/U ratio of the silicate Earth: Insights into mantle composition, structure and thermal evolution},
  year    = {2009},
  number  = {3–4},
  pages   = {361 - 369},
  volume  = {278},
  comment = {Téléchargé suite à la lecture de :
https://en.wikipedia.org/wiki/Thorium#Formation},
  doi     = {http://dx.doi.org/10.1016/j.epsl.2008.12.023},
}

@Comment{jabref-meta: databaseType:bibtex;}
@Siedlerchr
Copy link
Member

Thanks for your report. This looks like it's a duplicate of #7010 There is also a brief discussion on how to implement a possible fix.
The problem is that the # sign in bibtex is normally used to indicate BibTeX strings and JabRef tries to associate this somehow with a BibTeX string

@Siedlerchr
Copy link
Member

We now changed the whole logic and enable BibTeX string resolving only for a couple of fields. This can be adjusted in the options

@lavalade
Copy link
Author

Thanks a lot !
I really like JabRef and I use it for many years now (from the start of my PhD), this bug was pretty minor, but it’s great it’s now fixed. Update goes brrr… 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants