JabRef / jabref

Graphical Java application for managing BibTeX and biblatex (.bib) databases
https://devdocs.jabref.org
MIT License
3.58k stars 2.5k forks source link

jabref automatically deletes entries showing wrong syntax #9668

Closed Processeer closed 1 year ago

Processeer commented 1 year ago

JabRef version

5.9 (latest release)

Operating system

Windows

Details on version and operating system

Windows 11 Pro - 22H2

Checked with the latest development build

Steps to reproduce the behaviour

  1. I created a field "library"
  2. I used the field to controll where the pdfs are saved in substructures in Preferences/LinkedFiles/FileDirectoryPattern
  3. I inserted in the filed library "Tagungen\2013\KWTK45\" using backslashes instead of slashes
  4. JabRef correctly moved the file into the folder, even created the subfolder
  5. instantly after saving the message appeared "...modified by onother prgram" saying entry was deleted

It took me a wile to check that the backslashes lead to this automatik removal of the entire entry. I would expect an error message or an automatic reeplacement into slashes. 2023-03-134

Appendix

@InProceedings{Wen2013,
  author           = {Tao Wen},
  booktitle        = {45. Kraftwerkstechnisches Kolloquium},
  library          = {Tagungen\2013\KWTK45\},
  title            = {Zünd- Und Abbrandverhalten Von Staubförmigen Brennstoffen},
  year             = {2013},
  comment          = {978-3-944310-04-06},
  creationdate     = {2023-03-13T13:09:59},
  file             = {:Tagungen/2013/KWTK45/Wen2013 - Zünd Und Abbrandverhalten Von Staubförmigen Brennstoffen.pdf:PDF},
  keywords         = {zündverzug, kohle, braunkohle, lausitz, zündofen, experiment, verzögerung, partikeldurchmesser, zündhyperbel, holzhackschnitzel, torf, staub, steinkohle, getreidestaub, brennstofffeuchte, biomasse, fossile, flüchtige, volatile, FIELD-Rohr, drop-tube, model, vergleich, berechnung,},
  modificationdate = {2023-03-13T13:17:17},
  owner            = {JOJ},
  url              = {https://fis.tu-dresden.de/portal/de/publications/zund-und-abbrandverhalten-von-staubfoermigen-brennstoffen(2f9dd517-794a-4cf5-9897-bc9eb6f125c6).html},
}
koppor commented 1 year ago

Thank you for reporting this!

The tricky thing is that the character \ is used as LaTeX command prefix. Moreover, it is used as escape character if one wants to have a closing brace literally in BibTeX. Example:

@misc{test,
  comment={The set \{\} denotes the empty set, too},
}

In your context, this surely makes no sence to interpret the backslash as escaping character. I am working on an improved parser.

Workaround: Until there is a fix, please replace \}, by }, in your BibTeX code.

koppor commented 1 year ago

Other thing, I never saw library in BibTeX. @Processeer Is this the way your institution puts the file path into a BibTeX entry? (This somehow refs https://github.com/JabRef/jabref/issues/98).

JabRef itself offers another sophisticated method to denote file directories: https://docs.jabref.org/finding-sorting-and-cleaning-entries/filelinks#directories-for-files. @Processeer

koppor commented 1 year ago

Code comment: This is caused by https://github.com/JabRef/jabref/blob/92aee56bc801d502154bd84e69a7cdc06ab36bb4/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java#L285. I wonder why the parser result is not displayed to the user. Think, we need to work on that (if JabRef reads a file from disk). Could be more complicated though.

koppor commented 1 year ago

Note that JabRef "simply" removed all entries following the inserted ones.

Example:

@Article{,
  author   = {test\},
  journal  = {Sci China Inf Sci},
  title    = {a\b\c\},
  year     = {2022},
  month    = sep,
  annote   = {lala},
  fjournal = {IEEE Transactions on Medical Imaging},
}

@Article{ostgaard2002,
  title = {energy},
  month = sep,
  year  = {2012},
}

ostgaard2002 was also removed, because the closing brace of the first entry was not parsed "as intended" and thus the next @Article was treated as belonging to the first article.

Maybe, we need to refine our parsing logic to "terminate" parsing the current entry and start parsing a new entry if @Article or a similar token is found.

Processeer commented 1 year ago

... we used this field exactly for this reason. The challenge was to be able to sort the files according to its "library" in a specific folder or subfolder on the hard drive. The library dependent folder does not work in this Case because we use only one Bib.

It works really nice until you copy the specific  subfolder from Windows Explorer into the field. Then you get the backslashes automatically.

Thats the way it hapened.

I know, it might be a little far of the normal usage. I just wanted to report this behaviour. I know whats behind it now, so you can decide If its important enough to be tackled.

Am 17.03.2023 um 08:26 schrieb Oliver Kopp:

Other thing, I never saw |library| in BibTeX. @Processeer https://github.com/Processeer Is this the way your institution puts the file path into a BibTeX entry? (This somehow refs #98 https://github.com/JabRef/jabref/issues/98).

JabRef itself offers another sophisticated method to denote file directories: https://docs.jabref.org/finding-sorting-and-cleaning-entries/filelinks#directories-for-files. @Processeer https://github.com/Processeer

— Reply to this email directly, view it on GitHub https://github.com/JabRef/jabref/issues/9668#issuecomment-1473290721, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6OZQPFAZASX5KOR5SHJLHTW4QG3DANCNFSM6AAAAAAVZIBRLI. You are receiving this because you were mentioned.Message ID: @.***>

koppor commented 1 year ago

... we used this field exactly for this reason. The challenge was to be able to sort the files according to its "library" in a specific folder or subfolder on the hard drive.

JabRef offers the grouping feature. They can be hierarchical, too. I think, there should be work done to have groups synchronized with the file directories. I opened an issue at https://github.com/koppor/jabref/issues/638 to refine the requirements. Please comment there if you have more ideas.

Thats the way it hapened. I know, it might be a little far of the normal usage. I just wanted to report this behaviour.

We really thank you for this, because you surely are not the first one hitting that behavior - and would not have been the last one.

I know whats behind it now, so you can decide If its important enough to be tackled.

We already tackled it at https://github.com/JabRef/jabref/pull/9677. The build at https://builds.jabref.org/main/ contains the fix and should work.

Siedlerchr commented 1 year ago

@koppor with File Directory Pattern you can also use the group field

koppor commented 1 year ago

Since this is fixed in main, I close this issue. Plrease reopen if the issue still persists.