From 2b7fad5386054ce91f0b9faa8e1f0bedefe8e8d5 Mon Sep 17 00:00:00 2001 From: Grzegorz Date: Thu, 16 Apr 2020 22:06:29 +0200 Subject: [PATCH 01/30] Remove dash from illegal characters. Fix #6295 #6257 #6252 --- .../org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java index d887ac16a15..3ebe7a909b0 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java @@ -27,7 +27,7 @@ public class BibtexKeyGenerator extends BracketedPattern { */ public static final String APPENDIX_CHARACTERS = "abcdefghijklmnopqrstuvwxyz"; private static final Logger LOGGER = LoggerFactory.getLogger(BibtexKeyGenerator.class); - private static final String KEY_ILLEGAL_CHARACTERS = "{}(),\\\"-#~^:'`ʹ"; + private static final String KEY_ILLEGAL_CHARACTERS = "{}(),\\\"#~^:'`ʹ"; private static final String KEY_UNWANTED_CHARACTERS = "{}(),\\\"-"; private final AbstractBibtexKeyPattern citeKeyPattern; private final BibDatabase database; From f332e4245fa195c48d8ad7fb87ce9bcdd6e9de0a Mon Sep 17 00:00:00 2001 From: Grzegorz Popiel Date: Fri, 17 Apr 2020 15:10:24 +0200 Subject: [PATCH 02/30] Update bibtexkey incompatible characters. Co-Authored-By: Oliver Kopp --- .../org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java index 3ebe7a909b0..ffb6588c365 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java @@ -27,7 +27,7 @@ public class BibtexKeyGenerator extends BracketedPattern { */ public static final String APPENDIX_CHARACTERS = "abcdefghijklmnopqrstuvwxyz"; private static final Logger LOGGER = LoggerFactory.getLogger(BibtexKeyGenerator.class); - private static final String KEY_ILLEGAL_CHARACTERS = "{}(),\\\"#~^:'`ʹ"; + private static final String KEY_ILLEGAL_CHARACTERS = "{}(),=\\\"#%~'`ʹ"; private static final String KEY_UNWANTED_CHARACTERS = "{}(),\\\"-"; private final AbstractBibtexKeyPattern citeKeyPattern; private final BibDatabase database; From 38687aa432d81f5ba933169da0891d28a0653dd6 Mon Sep 17 00:00:00 2001 From: Matthias Mayr Date: Thu, 16 Apr 2020 22:12:02 +0200 Subject: [PATCH 03/30] Add missing abbreviated journal names (#6292) --- src/main/resources/journals/journalList.csv | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/resources/journals/journalList.csv b/src/main/resources/journals/journalList.csv index 993a4650bc5..0ebc39f583d 100644 --- a/src/main/resources/journals/journalList.csv +++ b/src/main/resources/journals/journalList.csv @@ -450,6 +450,7 @@ Advanced Materials;Adv. Mater.;; Advanced Materials and Processes;Adv. Mater. Processes;; Advanced Materials for Optics and Electronics;Adv. Mater. Opt. Electron.;; Advanced Materials Forum;Adv. Mater. Forum;; +Advanced Modeling and Simulation in Engineering Sciences;Adv. Model. Simul. Eng. Sci.;; Advanced Optical Materials;Adv. Opt. Mater.;; Advanced Powder Technology;Adv. Powder Technol.;; Advanced Practice Nursing Quarterly;Adv. Pract. Nurs. Q.;; @@ -1345,6 +1346,7 @@ Appled Entomology and Zoology;Appl. Entomol. Zool.;; Applicable Algebra in Engineering, Communication and Computing;Appl. Algebra Eng. Commun. Comput.;; Applications and Applied Mathematics;Appl. Appl. Math.;; Applications in Plant Sciences;Appl. Plant Sci.;; +Applications of Mathematics;Appl. Math.;; Applied Accoustics;Appl. Acoust.;; Applied Adhesion Science;Appl. Adhes. Sci.;; Applied and Computational Harmonic Analysis;Appl. Comput. Harmon. Anal.;; @@ -3308,7 +3310,7 @@ Climate Dynamics;Climate Dyn.;; Climate of the Past;Clim. Past;; Climate of the Past Discussion;Clim. Past Discuss.;; Climate Risk Management;Clim. Risk Manage.;; -Climatic Change;Climatic Change;; +Climatic Change;Clim. Change;; Climatological Bulletin;Climatol. Bull.;; Clinic;Clinic (Paris);; Clinic Odontologia;Clin. Odontol.;; @@ -3645,6 +3647,7 @@ Computational Condensed Matter;Comput. Condens. Matter;; Computational Geometry: Theory and Applications;Comput. Geom. Theory Appl.;; Computational Geosciences;Comput. Geosci.;; Computational Intelligence;Comput. Intell.;; +Computational Materials Science;Comput. Mater. Sci.;; Computational Mathematics and Mathematical Physics;Comput. Math. Math. Phys.;; Computational Mathematics and Modeling;Comput. Math. Model.;; Computational Mechanics;Comput. Mech.;; @@ -4576,6 +4579,7 @@ Engineering Analysis with Boundary Elements;Eng. Anal. Boundary Elem.;; Engineering and Mining Journal;Eng. Min. J.;; Engineering and Mining Journal Press;Eng. Min. J. Press;; Engineering Applications of Artificial Intelligence;Eng. Appl. Artif. Intell.;; +Engineering Computations;Eng. Comput.;; Engineering Failure Analysis;Eng. Fail. Anal.;; Engineering Fracture Mechanics;Eng. Fract. Mech.;; Engineering Geology;Eng. Geol.;; @@ -6352,6 +6356,7 @@ Instruments and Experiment Techniques;Instrum. Exp. Tech.;; Integrated Environmental Assessment and Management;Integr. Environ. Assess. Manage.;; Integrated Ferroelectrics;Integr. Ferroelectr.;; Integrated Healthcare Report;Integr. Healthc. Rep.;; +Integrating Materials and Manufacturing Innovation;Integr. Mater. Manuf. Innov.;; Integrative and Comparative Biology;Integr. Comp. Biol.;; Integrative Biology;Integr. Biol.;; Integrative Cancer Therapies;Integr. Cancer Ther.;; @@ -7701,6 +7706,7 @@ Journal of Computational Electronics;J. Comput. Electron.;; Journal of Computational Methods in Science and Engineering;J. Comput. Methods Sci. Eng.;; Journal of Computational Neuroscience;J. Comput. Neurosci.;; Journal of Computational Physics;J. Comput. Phys.;; +Journal of Computational Science;J. Comput. Sci.;; Journal of Computed Tomography;J. Comput. Tomogr.;; Journal of Computer and System Sciences International;J. Comput. Syst. Sci. Int.;; Journal of Computer Assisted Tomography;J. Comput. Assisted Tomogr.;; @@ -10524,7 +10530,7 @@ MRS Internet Journal of Nitride Semiconductor Research;MRS Internet J. Nitride S MSDA Journal;MSDA J.;; Mucopolysaccharides Biochimica et Biophysica Acta, Specialized Section on Mucoproteins and Mucopolysaccharides;Biochim. Biophys. Acta, Spec. Sect. Mucoproteins;BBASFB; Mull und Abfall;Mull Abfall;; -Multibody System Dynamics;Multibody Sys.Dyn.;; +Multibody System Dynamics;Multibody Sys. Dyn.;; Multidimensional Systems and Signal Processing;Multidimension. Syst. Signal Process.;; Multiple Sclerosis;Mult. Scler.;; Multis;Multis;; @@ -11112,6 +11118,7 @@ Nukleonika;Nukleonika;; Numerical Analysis and Applications;Numer. Anal. Appl.;; Numerical Heat Transfer Part A;Numer. Heat Transfer, Part A;; Numerical Heat Transfer Part B;Numer. Heat Transfer, Part B;; +Numerical Linear Algebra with Applications;Numer. Linear Algebra Appl.;; Nuntius Radiologicus;Nunt. Radiol.;; Nuova Rivista di Neurologia;Nuova Riv. Neurol.;; Nuovi Annali d'Igiene e Microbiologia;Nuovi Ann. Ig. Microbiol.;; @@ -13660,6 +13667,7 @@ SIAM Journal on Mathematical Analysis;SIAM J. Math. Anal.;; SIAM Journal on Matrix Analysis and Applications;SIAM J. Matrix Anal. Appl.;; SIAM Journal on Numerical Analysis;SIAM J. Numer. Anal.;; SIAM Journal on Optimization;SIAM J. Optim.;; +SIAM Journal on Scientific and Statistical Computing;SIAM J. Sci. Stat. Comput.;; SIAM Review;SIAM Rev.;; Sichuan Da Xue Xue Bao. Yi Xue Ban (Journal of Sichuan University. Medical Science Edition);Sichuan Da Xue Xue Bao Yi Xue Ban;; Sichuan Yi Xue Yuan Xue Bao (Acta Academiae Medicinae Sichuan);Sichuan Yi Xue Yuan Xue Bao;; From feb6709427f81f72bd3ebdd95f53f04e6c8281b1 Mon Sep 17 00:00:00 2001 From: Grzegorz Date: Fri, 17 Apr 2020 15:38:26 +0200 Subject: [PATCH 04/30] Change in CHANGELOG.md described. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff6295cde77..302680cc071 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,8 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Fixed +- We fixed an issue with incompatible characters at BibTeX-Key [#6257](https://github.com/JabRef/jabref/issues/6257) +- We fixed an issue where dash was reported as illegal BibTeX-Key [#6295](https://github.com/JabRef/jabref/issues/6295) - We greatly improved the performance of the overall application and many operations. [#5071](https://github.com/JabRef/jabref/issues/5071) - We fixed an issue where sort by priority was broken. [#6222](https://github.com/JabRef/jabref/issues/6222) - We fixed an issue where opening a library from the recent libraries menu was not possible. [#5939](https://github.com/JabRef/jabref/issues/5939) From 23d9720dc7673a7a541b284a400a97318c35190d Mon Sep 17 00:00:00 2001 From: Grzegorz Date: Fri, 17 Apr 2020 15:49:19 +0200 Subject: [PATCH 05/30] Revert "Add missing abbreviated journal names (#6292)" This reverts commit 38687aa4 --- src/main/resources/journals/journalList.csv | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main/resources/journals/journalList.csv b/src/main/resources/journals/journalList.csv index 0ebc39f583d..993a4650bc5 100644 --- a/src/main/resources/journals/journalList.csv +++ b/src/main/resources/journals/journalList.csv @@ -450,7 +450,6 @@ Advanced Materials;Adv. Mater.;; Advanced Materials and Processes;Adv. Mater. Processes;; Advanced Materials for Optics and Electronics;Adv. Mater. Opt. Electron.;; Advanced Materials Forum;Adv. Mater. Forum;; -Advanced Modeling and Simulation in Engineering Sciences;Adv. Model. Simul. Eng. Sci.;; Advanced Optical Materials;Adv. Opt. Mater.;; Advanced Powder Technology;Adv. Powder Technol.;; Advanced Practice Nursing Quarterly;Adv. Pract. Nurs. Q.;; @@ -1346,7 +1345,6 @@ Appled Entomology and Zoology;Appl. Entomol. Zool.;; Applicable Algebra in Engineering, Communication and Computing;Appl. Algebra Eng. Commun. Comput.;; Applications and Applied Mathematics;Appl. Appl. Math.;; Applications in Plant Sciences;Appl. Plant Sci.;; -Applications of Mathematics;Appl. Math.;; Applied Accoustics;Appl. Acoust.;; Applied Adhesion Science;Appl. Adhes. Sci.;; Applied and Computational Harmonic Analysis;Appl. Comput. Harmon. Anal.;; @@ -3310,7 +3308,7 @@ Climate Dynamics;Climate Dyn.;; Climate of the Past;Clim. Past;; Climate of the Past Discussion;Clim. Past Discuss.;; Climate Risk Management;Clim. Risk Manage.;; -Climatic Change;Clim. Change;; +Climatic Change;Climatic Change;; Climatological Bulletin;Climatol. Bull.;; Clinic;Clinic (Paris);; Clinic Odontologia;Clin. Odontol.;; @@ -3647,7 +3645,6 @@ Computational Condensed Matter;Comput. Condens. Matter;; Computational Geometry: Theory and Applications;Comput. Geom. Theory Appl.;; Computational Geosciences;Comput. Geosci.;; Computational Intelligence;Comput. Intell.;; -Computational Materials Science;Comput. Mater. Sci.;; Computational Mathematics and Mathematical Physics;Comput. Math. Math. Phys.;; Computational Mathematics and Modeling;Comput. Math. Model.;; Computational Mechanics;Comput. Mech.;; @@ -4579,7 +4576,6 @@ Engineering Analysis with Boundary Elements;Eng. Anal. Boundary Elem.;; Engineering and Mining Journal;Eng. Min. J.;; Engineering and Mining Journal Press;Eng. Min. J. Press;; Engineering Applications of Artificial Intelligence;Eng. Appl. Artif. Intell.;; -Engineering Computations;Eng. Comput.;; Engineering Failure Analysis;Eng. Fail. Anal.;; Engineering Fracture Mechanics;Eng. Fract. Mech.;; Engineering Geology;Eng. Geol.;; @@ -6356,7 +6352,6 @@ Instruments and Experiment Techniques;Instrum. Exp. Tech.;; Integrated Environmental Assessment and Management;Integr. Environ. Assess. Manage.;; Integrated Ferroelectrics;Integr. Ferroelectr.;; Integrated Healthcare Report;Integr. Healthc. Rep.;; -Integrating Materials and Manufacturing Innovation;Integr. Mater. Manuf. Innov.;; Integrative and Comparative Biology;Integr. Comp. Biol.;; Integrative Biology;Integr. Biol.;; Integrative Cancer Therapies;Integr. Cancer Ther.;; @@ -7706,7 +7701,6 @@ Journal of Computational Electronics;J. Comput. Electron.;; Journal of Computational Methods in Science and Engineering;J. Comput. Methods Sci. Eng.;; Journal of Computational Neuroscience;J. Comput. Neurosci.;; Journal of Computational Physics;J. Comput. Phys.;; -Journal of Computational Science;J. Comput. Sci.;; Journal of Computed Tomography;J. Comput. Tomogr.;; Journal of Computer and System Sciences International;J. Comput. Syst. Sci. Int.;; Journal of Computer Assisted Tomography;J. Comput. Assisted Tomogr.;; @@ -10530,7 +10524,7 @@ MRS Internet Journal of Nitride Semiconductor Research;MRS Internet J. Nitride S MSDA Journal;MSDA J.;; Mucopolysaccharides Biochimica et Biophysica Acta, Specialized Section on Mucoproteins and Mucopolysaccharides;Biochim. Biophys. Acta, Spec. Sect. Mucoproteins;BBASFB; Mull und Abfall;Mull Abfall;; -Multibody System Dynamics;Multibody Sys. Dyn.;; +Multibody System Dynamics;Multibody Sys.Dyn.;; Multidimensional Systems and Signal Processing;Multidimension. Syst. Signal Process.;; Multiple Sclerosis;Mult. Scler.;; Multis;Multis;; @@ -11118,7 +11112,6 @@ Nukleonika;Nukleonika;; Numerical Analysis and Applications;Numer. Anal. Appl.;; Numerical Heat Transfer Part A;Numer. Heat Transfer, Part A;; Numerical Heat Transfer Part B;Numer. Heat Transfer, Part B;; -Numerical Linear Algebra with Applications;Numer. Linear Algebra Appl.;; Nuntius Radiologicus;Nunt. Radiol.;; Nuova Rivista di Neurologia;Nuova Riv. Neurol.;; Nuovi Annali d'Igiene e Microbiologia;Nuovi Ann. Ig. Microbiol.;; @@ -13667,7 +13660,6 @@ SIAM Journal on Mathematical Analysis;SIAM J. Math. Anal.;; SIAM Journal on Matrix Analysis and Applications;SIAM J. Matrix Anal. Appl.;; SIAM Journal on Numerical Analysis;SIAM J. Numer. Anal.;; SIAM Journal on Optimization;SIAM J. Optim.;; -SIAM Journal on Scientific and Statistical Computing;SIAM J. Sci. Stat. Comput.;; SIAM Review;SIAM Rev.;; Sichuan Da Xue Xue Bao. Yi Xue Ban (Journal of Sichuan University. Medical Science Edition);Sichuan Da Xue Xue Bao Yi Xue Ban;; Sichuan Yi Xue Yuan Xue Bao (Acta Academiae Medicinae Sichuan);Sichuan Yi Xue Yuan Xue Bao;; From a90ac6049f904afe53e401b633a467b4f0b97f6f Mon Sep 17 00:00:00 2001 From: Grzegorz Popiel Date: Sat, 18 Apr 2020 00:21:24 +0200 Subject: [PATCH 06/30] Update CHANGELOG.md Co-Authored-By: Oliver Kopp --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 302680cc071..93c4d7c17db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Fixed - We fixed an issue with incompatible characters at BibTeX-Key [#6257](https://github.com/JabRef/jabref/issues/6257) -- We fixed an issue where dash was reported as illegal BibTeX-Key [#6295](https://github.com/JabRef/jabref/issues/6295) +- We fixed an issue where dash (`-`) was reported as illegal BibTeX key [#6295](https://github.com/JabRef/jabref/issues/6295) - We greatly improved the performance of the overall application and many operations. [#5071](https://github.com/JabRef/jabref/issues/5071) - We fixed an issue where sort by priority was broken. [#6222](https://github.com/JabRef/jabref/issues/6222) - We fixed an issue where opening a library from the recent libraries menu was not possible. [#5939](https://github.com/JabRef/jabref/issues/5939) From ed42ac17a0080734378b61bc82c8feec766143ed Mon Sep 17 00:00:00 2001 From: Grzegorz Popiel Date: Sat, 18 Apr 2020 00:21:32 +0200 Subject: [PATCH 07/30] Update CHANGELOG.md Co-Authored-By: Oliver Kopp --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93c4d7c17db..ee46da53819 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Fixed -- We fixed an issue with incompatible characters at BibTeX-Key [#6257](https://github.com/JabRef/jabref/issues/6257) +- We fixed an issue with incompatible characters at BibTeX key [#6257](https://github.com/JabRef/jabref/issues/6257) - We fixed an issue where dash (`-`) was reported as illegal BibTeX key [#6295](https://github.com/JabRef/jabref/issues/6295) - We greatly improved the performance of the overall application and many operations. [#5071](https://github.com/JabRef/jabref/issues/5071) - We fixed an issue where sort by priority was broken. [#6222](https://github.com/JabRef/jabref/issues/6222) From 6fc964554b037782dd23338097c236c37ef71416 Mon Sep 17 00:00:00 2001 From: Grzegorz Date: Sat, 18 Apr 2020 00:40:13 +0200 Subject: [PATCH 08/30] Renamed 'KEY_UNWANTED_CHARACTERS' to 'KEY_CHARACTERS_CAUSING_PARSING_ERRORS'. --- .../jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java index ffb6588c365..a9ad4e8de0f 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java @@ -24,11 +24,12 @@ public class BibtexKeyGenerator extends BracketedPattern { /* * All single characters that we can use for extending a key to make it unique. + * KEY_CHARACTERS_CAUSING_PARSING_ERRORS is a subset of KEY_ILLEGAL_CHARACTERS */ public static final String APPENDIX_CHARACTERS = "abcdefghijklmnopqrstuvwxyz"; private static final Logger LOGGER = LoggerFactory.getLogger(BibtexKeyGenerator.class); private static final String KEY_ILLEGAL_CHARACTERS = "{}(),=\\\"#%~'`ʹ"; - private static final String KEY_UNWANTED_CHARACTERS = "{}(),\\\"-"; + private static final String KEY_CHARACTERS_CAUSING_PARSING_ERRORS = "{}(),\\\"-"; private final AbstractBibtexKeyPattern citeKeyPattern; private final BibDatabase database; private final BibtexKeyPatternPreferences bibtexKeyPatternPreferences; @@ -81,7 +82,7 @@ public static String removeUnwantedCharacters(String key, boolean enforceLegalKe StringBuilder newKey = new StringBuilder(); for (int i = 0; i < key.length(); i++) { char c = key.charAt(i); - if (KEY_UNWANTED_CHARACTERS.indexOf(c) == -1) { + if (KEY_CHARACTERS_CAUSING_PARSING_ERRORS.indexOf(c) == -1) { newKey.append(c); } } From 00f8c927c195c599e10f8df70a0edef605411418 Mon Sep 17 00:00:00 2001 From: Grzegorz Date: Wed, 22 Apr 2020 21:55:14 +0200 Subject: [PATCH 09/30] =?UTF-8?q?Merged=20illegal=20`KEY=5FILLEGAL=5FCHARA?= =?UTF-8?q?CTERS`=20and=20disallowed=20`KEY=5FCHARACTERS=5FCAUSING=5FPARSI?= =?UTF-8?q?NG=5FERRORS`=20into=20`KEY=5FDISALLOWED=5FCHARACTERS`=20and=20r?= =?UTF-8?q?emoved:=20`=20=CA=B9.=20Added=20new=20KEY=5FUNWANTED=5FCHARACTE?= =?UTF-8?q?RS.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/bibtexkeypattern/BibtexKeyGenerator.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java index a9ad4e8de0f..01010c982c7 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java @@ -24,12 +24,12 @@ public class BibtexKeyGenerator extends BracketedPattern { /* * All single characters that we can use for extending a key to make it unique. - * KEY_CHARACTERS_CAUSING_PARSING_ERRORS is a subset of KEY_ILLEGAL_CHARACTERS */ public static final String APPENDIX_CHARACTERS = "abcdefghijklmnopqrstuvwxyz"; private static final Logger LOGGER = LoggerFactory.getLogger(BibtexKeyGenerator.class); - private static final String KEY_ILLEGAL_CHARACTERS = "{}(),=\\\"#%~'`ʹ"; - private static final String KEY_CHARACTERS_CAUSING_PARSING_ERRORS = "{}(),\\\"-"; + // Source of DISALLOWED characters: https://tex.stackexchange.com/a/408548/9075 + private static final String KEY_DISALLOWED_CHARACTERS = "{}(),=\\\"#%~'"; + private static String KEY_UNWANTED_CHARACTERS = "-`ʹ:!;?^+"; private final AbstractBibtexKeyPattern citeKeyPattern; private final BibDatabase database; private final BibtexKeyPatternPreferences bibtexKeyPatternPreferences; @@ -82,7 +82,7 @@ public static String removeUnwantedCharacters(String key, boolean enforceLegalKe StringBuilder newKey = new StringBuilder(); for (int i = 0; i < key.length(); i++) { char c = key.charAt(i); - if (KEY_CHARACTERS_CAUSING_PARSING_ERRORS.indexOf(c) == -1) { + if (KEY_UNWANTED_CHARACTERS.indexOf(c) == -1) { newKey.append(c); } } @@ -92,7 +92,7 @@ public static String removeUnwantedCharacters(String key, boolean enforceLegalKe StringBuilder newKey = new StringBuilder(); for (int i = 0; i < key.length(); i++) { char c = key.charAt(i); - if (KEY_ILLEGAL_CHARACTERS.indexOf(c) == -1) { + if (KEY_DISALLOWED_CHARACTERS.indexOf(c) == -1) { newKey.append(c); } } From e39cca3362f88101a488c638aaf5c90217ae90a5 Mon Sep 17 00:00:00 2001 From: Grzegorz Date: Thu, 23 Apr 2020 02:36:17 +0200 Subject: [PATCH 10/30] Adapted the tests according to code updates. --- .../bibtexkeypattern/BibtexKeyGeneratorTest.java | 16 ++++++++-------- .../MakeLabelWithDatabaseTest.java | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java index 254a9c50bf0..32d74769777 100644 --- a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java +++ b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java @@ -195,8 +195,8 @@ void testMakeLabelAndCheckLegalKeys() throws ParseException { */ @Test void testMakeLabelAndCheckLegalKeysAccentGrave() throws ParseException { - Optional entry0 = BibtexParser.singleFromString( - "@ARTICLE{kohn, author={Andreas Àöning}, year={2000}}", importFormatPreferences, fileMonitor); + Optional entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Àöning}, year={2000}}", + importFormatPreferences, fileMonitor); assertEquals("Aoe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); @@ -227,7 +227,7 @@ void testMakeLabelAndCheckLegalKeysAccentGrave() throws ParseException { entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Oraib Al-Ketan}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("AlK", + assertEquals("Al-", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); @@ -239,7 +239,7 @@ void testMakeLabelAndCheckLegalKeysAccentGrave() throws ParseException { entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andrés Aʹrnold}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Arn", + assertEquals("Aʹr", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); } @@ -943,14 +943,14 @@ void crossrefkeywordsNKeywordsSeparatedBySpace() { @Test void testCheckLegalKeyEnforceLegal() { assertEquals("AAAA", BibtexKeyGenerator.cleanKey("AA AA", true)); - assertEquals("SPECIALCHARS", BibtexKeyGenerator.cleanKey("SPECIAL CHARS#{\\\"}~,^", true)); + assertEquals("SPECIALCHARS", BibtexKeyGenerator.cleanKey("SPECIAL CHARS#{\\\"}~,", true)); assertEquals("", BibtexKeyGenerator.cleanKey("\n\t\r", true)); } @Test void testCheckLegalKeyDoNotEnforceLegal() { assertEquals("AAAA", BibtexKeyGenerator.cleanKey("AA AA", false)); - assertEquals("SPECIALCHARS#~^", BibtexKeyGenerator.cleanKey("SPECIAL CHARS#{\\\"}~,^", false)); + assertEquals("SPECIALCHARS#{\\\"}~,", BibtexKeyGenerator.cleanKey("SPECIAL CHARS#{\\\"}~,", false)); assertEquals("", BibtexKeyGenerator.cleanKey("\n\t\r", false)); } @@ -1002,14 +1002,14 @@ void testcrossrefShorttitleInitials() { void generateKeyStripsColonFromTitle() throws Exception { BibEntry entry = new BibEntry(); entry.setField(StandardField.TITLE, "Green Scheduling of: Whatever"); - assertEquals("GreenSchedulingOfWhatever", BibtexKeyGenerator.generateKey(entry, "title")); + assertEquals("GreenSchedulingOf:Whatever", BibtexKeyGenerator.generateKey(entry, "title")); } @Test void generateKeyStripsApostropheFromTitle() throws Exception { BibEntry entry = new BibEntry(); entry.setField(StandardField.TITLE, "Green Scheduling of `Whatever`"); - assertEquals("GreenSchedulingofWhatever", BibtexKeyGenerator.generateKey(entry, "title")); + assertEquals("GreenSchedulingof`Whatever`", BibtexKeyGenerator.generateKey(entry, "title")); } @Test diff --git a/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java b/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java index 584f14d05f1..7f0134ba0cb 100644 --- a/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java +++ b/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java @@ -211,7 +211,7 @@ void generateKeyEmptyFieldNoColonInDefaultText() { bibtexKeyPattern.setDefaultValue("[author:(Problem:No Author Provided)]"); entry.clearField(StandardField.AUTHOR); new BibtexKeyGenerator(bibtexKeyPattern, database, preferences).generateAndSetKey(entry); - assertEquals(Optional.of("ProblemNoAuthorProvided"), entry.getCiteKeyOptional()); + assertEquals(Optional.of("Problem:NoAuthorProvided"), entry.getCiteKeyOptional()); } @Test @@ -398,7 +398,7 @@ void generateKeyTitleRegexe() { bibtexKeyPattern.setDefaultValue("[title:regex(\" \",\"-\")]"); entry.setField(StandardField.TITLE, "Please replace the spaces"); new BibtexKeyGenerator(bibtexKeyPattern, database, preferences).generateAndSetKey(entry); - assertEquals(Optional.of("PleaseReplacetheSpaces"), entry.getCiteKeyOptional()); + assertEquals(Optional.of("Please-Replace-the-Spaces"), entry.getCiteKeyOptional()); } @Test From 471ec0e11c71d74e0bfaaa4a9250f27b82a5d32c Mon Sep 17 00:00:00 2001 From: Grzegorz Date: Wed, 29 Apr 2020 00:39:27 +0200 Subject: [PATCH 11/30] Removed 'enforceLegalKey'. Changed 'KEY_ILLEGAL_CHARACTERS' and 'KEY_UNWANTED_CHARACTERS'. Updated tests. Changed error warning about disallowed characters. --- ...CustomizeGeneralFieldsDialogViewModel.java | 5 +- .../bibtexkeypattern/BibtexKeyGenerator.java | 32 ++--- .../bibtexkeypattern/BracketedPattern.java | 2 +- .../importer/fileformat/EndnoteImporter.java | 4 +- .../jabref/logic/integrity/FieldCheckers.java | 4 +- .../integrity/ValidBibtexKeyChecker.java | 8 +- .../BibtexKeyGeneratorTest.java | 112 +++++++++--------- .../MakeLabelWithDatabaseTest.java | 4 +- 8 files changed, 76 insertions(+), 95 deletions(-) diff --git a/src/main/java/org/jabref/gui/customizefields/CustomizeGeneralFieldsDialogViewModel.java b/src/main/java/org/jabref/gui/customizefields/CustomizeGeneralFieldsDialogViewModel.java index 521b9ac1d76..6db4f644388 100644 --- a/src/main/java/org/jabref/gui/customizefields/CustomizeGeneralFieldsDialogViewModel.java +++ b/src/main/java/org/jabref/gui/customizefields/CustomizeGeneralFieldsDialogViewModel.java @@ -57,12 +57,13 @@ public void saveFields() { return; } - String testString = BibtexKeyGenerator.cleanKey(parts[1], preferences.getEnforceLegalKeys()); + String testString = BibtexKeyGenerator.cleanKey(parts[1]); if (!testString.equals(parts[1]) || (parts[1].indexOf('&') >= 0)) { String title = Localization.lang("Error"); String content = Localization.lang("Field names are not allowed to contain white space or the following " + "characters") - + ": # { } ( ) ~ , ^ & - \" ' ` ʹ \\"; + + "{ } ( ) , = \\ \" # % ~ '"; + dialogService.showInformationDialogAndWait(title, content); return; } diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java index 01010c982c7..6a2a7a6496a 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java @@ -1,6 +1,7 @@ package org.jabref.logic.bibtexkeypattern; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Objects; @@ -27,9 +28,9 @@ public class BibtexKeyGenerator extends BracketedPattern { */ public static final String APPENDIX_CHARACTERS = "abcdefghijklmnopqrstuvwxyz"; private static final Logger LOGGER = LoggerFactory.getLogger(BibtexKeyGenerator.class); - // Source of DISALLOWED characters: https://tex.stackexchange.com/a/408548/9075 - private static final String KEY_DISALLOWED_CHARACTERS = "{}(),=\\\"#%~'"; - private static String KEY_UNWANTED_CHARACTERS = "-`ʹ:!;?^+"; + // Source of disallowed characters : https://tex.stackexchange.com/a/408548/9075 + private static List disallowedCharacters = Arrays.asList('{', '}', '(', ')', ',', '=', '\\', '"', '#', '%', '~', '\''); + private static List unwantedCharacters = Arrays.asList('-', '`', 'ʹ', ':', '!', ';', '?', '^', '+'); private final AbstractBibtexKeyPattern citeKeyPattern; private final BibDatabase database; private final BibtexKeyPatternPreferences bibtexKeyPatternPreferences; @@ -74,36 +75,21 @@ private static String getAppendix(int number) { } } - public static String removeUnwantedCharacters(String key, boolean enforceLegalKey) { - if (!enforceLegalKey) { - // User doesn't want us to enforce legal characters. We must still look - // for whitespace and some characters such as commas, since these would - // interfere with parsing: - StringBuilder newKey = new StringBuilder(); - for (int i = 0; i < key.length(); i++) { - char c = key.charAt(i); - if (KEY_UNWANTED_CHARACTERS.indexOf(c) == -1) { - newKey.append(c); - } - } - return newKey.toString(); - } - + public static String removeUnwantedCharacters(String key) { StringBuilder newKey = new StringBuilder(); for (int i = 0; i < key.length(); i++) { char c = key.charAt(i); - if (KEY_DISALLOWED_CHARACTERS.indexOf(c) == -1) { + if (!disallowedCharacters.contains(c) && !unwantedCharacters.contains(c)) { newKey.append(c); } } - // Replace non-English characters like umlauts etc. with a sensible // letter or letter combination that bibtex can accept. return StringUtil.replaceSpecialCharacters(newKey.toString()); } - public static String cleanKey(String key, boolean enforceLegalKey) { - return removeUnwantedCharacters(key, enforceLegalKey).replaceAll("\\s", ""); + public static String cleanKey(String key) { + return removeUnwantedCharacters(key).replaceAll("\\s", ""); } public String generateKey(BibEntry entry) { @@ -136,7 +122,7 @@ public String generateKey(BibEntry entry) { } // Remove all illegal characters from the label. - label = cleanKey(label, bibtexKeyPatternPreferences.isEnforceLegalKey()); + label = cleanKey(label); stringBuilder.append(label); diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java index 8c0d7ff3a83..85d87ea4803 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java @@ -837,7 +837,7 @@ public static String authNofMth(String authorField, int n, int m) { */ public static String authN(String authString, int num, boolean isEnforceLegalKey) { String fa = firstAuthor(authString); - fa = BibtexKeyGenerator.removeUnwantedCharacters(fa, isEnforceLegalKey); + fa = BibtexKeyGenerator.removeUnwantedCharacters(fa); if (num > fa.length()) { num = fa.length(); } diff --git a/src/main/java/org/jabref/logic/importer/fileformat/EndnoteImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/EndnoteImporter.java index 794030a0423..c7838b6de6e 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/EndnoteImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/EndnoteImporter.java @@ -232,8 +232,8 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { type = StandardEntryType.MastersThesis; } } else if ("F".equals(prefix)) { - hm.put(InternalField.KEY_FIELD, BibtexKeyGenerator.cleanKey(val, - preferences.getBibtexKeyPatternPreferences().isEnforceLegalKey())); + hm.put(InternalField.KEY_FIELD, BibtexKeyGenerator.cleanKey(val + )); } } diff --git a/src/main/java/org/jabref/logic/integrity/FieldCheckers.java b/src/main/java/org/jabref/logic/integrity/FieldCheckers.java index c1aa8df913b..19bc12ee6f5 100644 --- a/src/main/java/org/jabref/logic/integrity/FieldCheckers.java +++ b/src/main/java/org/jabref/logic/integrity/FieldCheckers.java @@ -52,8 +52,8 @@ private static Multimap getAllMap(BibDatabaseContext databa fieldCheckers.put(StandardField.PAGES, new PagesChecker(databaseContext)); fieldCheckers.put(StandardField.URL, new UrlChecker()); fieldCheckers.put(StandardField.YEAR, new YearChecker()); - fieldCheckers.put(StandardField.KEY, new ValidBibtexKeyChecker(enforceLegalKey)); - fieldCheckers.put(InternalField.KEY_FIELD, new ValidBibtexKeyChecker(enforceLegalKey)); + fieldCheckers.put(StandardField.KEY, new ValidBibtexKeyChecker()); + fieldCheckers.put(InternalField.KEY_FIELD, new ValidBibtexKeyChecker()); if (databaseContext.isBiblatexMode()) { fieldCheckers.put(StandardField.DATE, new DateChecker()); diff --git a/src/main/java/org/jabref/logic/integrity/ValidBibtexKeyChecker.java b/src/main/java/org/jabref/logic/integrity/ValidBibtexKeyChecker.java index b18fd9272c3..74a0d99f830 100644 --- a/src/main/java/org/jabref/logic/integrity/ValidBibtexKeyChecker.java +++ b/src/main/java/org/jabref/logic/integrity/ValidBibtexKeyChecker.java @@ -11,19 +11,13 @@ */ public class ValidBibtexKeyChecker implements ValueChecker { - private final boolean enforceLegalKey; - - public ValidBibtexKeyChecker(boolean enforceLegalKey) { - this.enforceLegalKey = enforceLegalKey; - } - @Override public Optional checkValue(String value) { if (StringUtil.isNullOrEmpty(value)) { return Optional.of(Localization.lang("empty BibTeX key")); } - String cleaned = BibtexKeyGenerator.cleanKey(value, enforceLegalKey); + String cleaned = BibtexKeyGenerator.cleanKey(value); if (cleaned.equals(value)) { return Optional.empty(); diff --git a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java index 32d74769777..91e4e3a4e9e 100644 --- a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java +++ b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java @@ -57,7 +57,7 @@ void testAndInAuthorName() throws ParseException { importFormatPreferences, fileMonitor); assertEquals("Holland", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth", - new BibDatabase()), true)); + new BibDatabase()))); } @Test @@ -73,7 +73,7 @@ void testCrossrefAndInAuthorNames() throws Exception { assertEquals("Holland", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry1, "auth", - database), true)); + database))); } @Test @@ -82,7 +82,7 @@ void testAndAuthorNames() throws ParseException { Optional entry = BibtexParser.singleFromString(bibtexString, importFormatPreferences, fileMonitor); assertEquals("HerlandHaugeHelgeland", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry.get(), "authors3", - new BibDatabase()), true)); + new BibDatabase()))); } @Test @@ -98,7 +98,7 @@ void testCrossrefAndAuthorNames() throws Exception { assertEquals("HerlandHaugeHelgeland", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry1, "authors3", - database), true)); + database))); } @Test @@ -107,7 +107,7 @@ void testSpecialLatexCharacterInAuthorName() throws ParseException { "@ARTICLE{kohn, author={Simon Popovi\\v{c}ov\\'{a}}}", importFormatPreferences, fileMonitor); assertEquals("Popovicova", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry.get(), "auth", - new BibDatabase()), true)); + new BibDatabase()))); } /** @@ -121,73 +121,73 @@ void testMakeLabelAndCheckLegalKeys() throws ParseException { "@ARTICLE{kohn, author={Andreas Köning}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("Koe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Áöning}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("Aoe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Éöning}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("Eoe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Íöning}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("Ioe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Ĺöning}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("Loe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Ńöning}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("Noe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Óöning}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("Ooe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Ŕöning}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("Roe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Śöning}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("Soe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Úöning}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("Uoe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Ýöning}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("Yoe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Źöning}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("Zoe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); } /** @@ -199,49 +199,49 @@ void testMakeLabelAndCheckLegalKeysAccentGrave() throws ParseException { importFormatPreferences, fileMonitor); assertEquals("Aoe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Èöning}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("Eoe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Ìöning}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("Ioe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Òöning}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("Ooe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Ùöning}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("Uoe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Oraib Al-Ketan}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Al-", + assertEquals("AlK", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andrés D'Alessandro}, year={2000}}", importFormatPreferences, fileMonitor); assertEquals("DAl", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andrés Aʹrnold}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Aʹr", + assertEquals("Arn", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", - new BibDatabase()), true)); + new BibDatabase()))); } /** @@ -259,43 +259,43 @@ void testCheckLegalKey() { // "Ł ł Ő ő Ű ű Ŀ ŀ Ħ ħ Ð ð Þ þ Œ œ Æ æ Ø ø Å å Ə ə String accents = "ÀàÈèÌìÒòÙù  â Ĉ ĉ Ê ê Ĝ ĝ Ĥ ĥ Î î Ĵ ĵ Ô ô Ŝ ŝ Û û Ŵ ŵ Ŷ ŷ"; String expectedResult = "AaEeIiOoUuAaCcEeGgHhIiJjOoSsUuWwYy"; - assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents, true)); + assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents)); accents = "ÄäËëÏïÖöÜüŸÿ"; expectedResult = "AeaeEeIiOeoeUeueYy"; - assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents, true)); + assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents)); accents = "Ç ç Ģ ģ Ķ ķ Ļ ļ Ņ ņ Ŗ ŗ Ş ş Ţ ţ"; expectedResult = "CcGgKkLlNnRrSsTt"; - assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents, true)); + assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents)); accents = "Ă ă Ĕ ĕ Ğ ğ Ĭ ĭ Ŏ ŏ Ŭ ŭ"; expectedResult = "AaEeGgIiOoUu"; - assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents, true)); + assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents)); accents = "Ċ ċ Ė ė Ġ ġ İ ı Ż ż"; expectedResult = "CcEeGgIiZz"; - assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents, true)); + assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents)); accents = "Ą ą Ę ę Į į Ǫ ǫ Ų ų"; expectedResult = "AaEeIiOoUu"; // O or Q? o or q? - assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents, true)); + assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents)); accents = "Ā ā Ē ē Ī ī Ō ō Ū ū Ȳ ȳ"; expectedResult = "AaEeIiOoUuYy"; - assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents, true)); + assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents)); accents = "Ǎ ǎ Č č Ď ď Ě ě Ǐ ǐ Ľ ľ Ň ň Ǒ ǒ Ř ř Š š Ť ť Ǔ ǔ Ž ž"; expectedResult = "AaCcDdEeIiLlNnOoRrSsTtUuZz"; - assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents, true)); + assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents)); expectedResult = "AaEeIiNnOoUuYy"; accents = "ÃãẼẽĨĩÑñÕõŨũỸỹ"; - assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents, true)); + assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents)); accents = "Ḍ ḍ Ḥ ḥ Ḷ ḷ Ḹ ḹ Ṃ ṃ Ṇ ṇ Ṛ ṛ Ṝ ṝ Ṣ ṣ Ṭ ṭ"; expectedResult = "DdHhLlLlMmNnRrRrSsTt"; - assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents, true)); + assertEquals(expectedResult, BibtexKeyGenerator.cleanKey(accents)); String totest = "À à È è Ì ì Ò ò Ù ù  â Ĉ ĉ Ê ê Ĝ ĝ Ĥ ĥ Î î Ĵ ĵ Ô ô Ŝ ŝ Û û Ŵ ŵ Ŷ ŷ Ä ä Ë ë Ï ï Ö ö Ü ü Ÿ ÿ " + "à ã Ẽ ẽ Ĩ ĩ Ñ ñ Õ õ Ũ ũ Ỹ ỹ Ç ç Ģ ģ Ķ ķ Ļ ļ Ņ ņ Ŗ ŗ Ş ş Ţ ţ" @@ -305,7 +305,7 @@ void testCheckLegalKey() { String expectedResults = "AaEeIiOoUuAaCcEeGgHhIiJjOoSsUuWwYyAeaeEeIiOeoeUeueYy" + "AaEeIiNnOoUuYyCcGgKkLlNnRrSsTt" + "AaCcDdEeIiLlNnOoRrSsTtUuZz" + "AaEeIiOoUuYy" + "AaEeGgIiOoUu" + "CcEeGgIiZzAaEeIiOoUu" + "DdHhLlLlMmNnRrRrSsTt"; - assertEquals(expectedResults, BibtexKeyGenerator.cleanKey(totest, true)); + assertEquals(expectedResults, BibtexKeyGenerator.cleanKey(totest)); } @Test @@ -330,7 +330,7 @@ void testUniversity() throws ParseException { "@ARTICLE{kohn, author={{Link{\\\"{o}}ping University}}}", importFormatPreferences, fileMonitor); assertEquals("UniLinkoeping", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry.get(), "auth", - new BibDatabase()), true)); + new BibDatabase()))); } @Test @@ -346,7 +346,7 @@ void testcrossrefUniversity() throws Exception { assertEquals("UniLinkoeping", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry1, "auth", - database), true)); + database))); } @Test @@ -356,7 +356,7 @@ void testDepartment() throws ParseException { importFormatPreferences, fileMonitor); assertEquals("UniLinkoepingEE", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry.get(), "auth", - new BibDatabase()), true)); + new BibDatabase()))); } @Test @@ -372,7 +372,7 @@ void testcrossrefDepartment() throws Exception { assertEquals("UniLinkoepingEE", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry1, "auth", - database), true)); + database))); } @Test @@ -382,7 +382,7 @@ void testSchool() throws ParseException { importFormatPreferences, fileMonitor); assertEquals("UniLinkoepingCE", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry.get(), "auth", - new BibDatabase()), true)); + new BibDatabase()))); } @Test @@ -398,7 +398,7 @@ void testcrossrefSchool() throws Exception { assertEquals("UniLinkoepingCE", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry1, "auth", - database), true)); + database))); } @Test @@ -407,7 +407,7 @@ void testInstituteOfTechnology() throws ParseException { "@ARTICLE{kohn, author={{Massachusetts Institute of Technology}}}", importFormatPreferences, fileMonitor); assertEquals("MIT", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry.get(), "auth", - new BibDatabase()), true)); + new BibDatabase()))); } @Test @@ -423,7 +423,7 @@ void testcrossrefInstituteOfTechnology() throws Exception { assertEquals("MIT", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry1, "auth", - database), true)); + database))); } @Test @@ -942,22 +942,22 @@ void crossrefkeywordsNKeywordsSeparatedBySpace() { @Test void testCheckLegalKeyEnforceLegal() { - assertEquals("AAAA", BibtexKeyGenerator.cleanKey("AA AA", true)); - assertEquals("SPECIALCHARS", BibtexKeyGenerator.cleanKey("SPECIAL CHARS#{\\\"}~,", true)); - assertEquals("", BibtexKeyGenerator.cleanKey("\n\t\r", true)); + assertEquals("AAAA", BibtexKeyGenerator.cleanKey("AA AA")); + assertEquals("SPECIALCHARS", BibtexKeyGenerator.cleanKey("SPECIAL CHARS#{\\\"}~,")); + assertEquals("", BibtexKeyGenerator.cleanKey("\n\t\r")); } @Test void testCheckLegalKeyDoNotEnforceLegal() { - assertEquals("AAAA", BibtexKeyGenerator.cleanKey("AA AA", false)); - assertEquals("SPECIALCHARS#{\\\"}~,", BibtexKeyGenerator.cleanKey("SPECIAL CHARS#{\\\"}~,", false)); - assertEquals("", BibtexKeyGenerator.cleanKey("\n\t\r", false)); + assertEquals("AAAA", BibtexKeyGenerator.cleanKey("AA AA")); + assertEquals("SPECIALCHARS", BibtexKeyGenerator.cleanKey("SPECIAL CHARS#{\\\"}~,^")); + assertEquals("", BibtexKeyGenerator.cleanKey("\n\t\r")); } @Test void testCheckLegalNullInNullOut() { - assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.cleanKey(null, true)); - assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.cleanKey(null, false)); + assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.cleanKey(null)); + assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.cleanKey(null)); } @Test @@ -1002,14 +1002,14 @@ void testcrossrefShorttitleInitials() { void generateKeyStripsColonFromTitle() throws Exception { BibEntry entry = new BibEntry(); entry.setField(StandardField.TITLE, "Green Scheduling of: Whatever"); - assertEquals("GreenSchedulingOf:Whatever", BibtexKeyGenerator.generateKey(entry, "title")); + assertEquals("GreenSchedulingOfWhatever", BibtexKeyGenerator.generateKey(entry, "title")); } @Test void generateKeyStripsApostropheFromTitle() throws Exception { BibEntry entry = new BibEntry(); entry.setField(StandardField.TITLE, "Green Scheduling of `Whatever`"); - assertEquals("GreenSchedulingof`Whatever`", BibtexKeyGenerator.generateKey(entry, "title")); + assertEquals("GreenSchedulingofWhatever", BibtexKeyGenerator.generateKey(entry, "title")); } @Test diff --git a/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java b/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java index 7f0134ba0cb..584f14d05f1 100644 --- a/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java +++ b/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java @@ -211,7 +211,7 @@ void generateKeyEmptyFieldNoColonInDefaultText() { bibtexKeyPattern.setDefaultValue("[author:(Problem:No Author Provided)]"); entry.clearField(StandardField.AUTHOR); new BibtexKeyGenerator(bibtexKeyPattern, database, preferences).generateAndSetKey(entry); - assertEquals(Optional.of("Problem:NoAuthorProvided"), entry.getCiteKeyOptional()); + assertEquals(Optional.of("ProblemNoAuthorProvided"), entry.getCiteKeyOptional()); } @Test @@ -398,7 +398,7 @@ void generateKeyTitleRegexe() { bibtexKeyPattern.setDefaultValue("[title:regex(\" \",\"-\")]"); entry.setField(StandardField.TITLE, "Please replace the spaces"); new BibtexKeyGenerator(bibtexKeyPattern, database, preferences).generateAndSetKey(entry); - assertEquals(Optional.of("Please-Replace-the-Spaces"), entry.getCiteKeyOptional()); + assertEquals(Optional.of("PleaseReplacetheSpaces"), entry.getCiteKeyOptional()); } @Test From 19e0879bd99349e48b3fb0e9c761b753e615795d Mon Sep 17 00:00:00 2001 From: Grzegorz Date: Fri, 1 May 2020 20:00:04 +0200 Subject: [PATCH 12/30] Removed "Enforce legal characters in BibTeX keys" option in the preferences (General tab). Removed 'ENFORCE_LEGAL_BIBTEX_KEY' from JabRefPreferences.java. Added "Remove the following characters:" field in "BibTeX key generator" tab in the preferences for the unwanted characters. Added 'DEFAULT_UNWANTED_BIBTEX_KEY_CHARACTERS' to JabRefPreferences.java as defaults. Revert 'avoidOverwritingCiteKey' - mistakenly removed in previous commit from BibtexKeyPatternPreferences.java. --- ...CustomizeGeneralFieldsDialogViewModel.java | 3 ++- .../jabref/gui/fieldeditors/FieldEditors.java | 1 - .../gui/integrity/IntegrityCheckAction.java | 1 - .../gui/preferences/BibtexKeyPatternTab.fxml | 5 ++++ .../preferences/BibtexKeyPatternTabView.java | 2 ++ .../BibtexKeyPatternTabViewModel.java | 5 ++++ .../jabref/gui/preferences/GeneralTab.fxml | 1 - .../gui/preferences/GeneralTabView.java | 2 -- .../gui/preferences/GeneralTabViewModel.java | 5 ---- .../bibtexkeypattern/BibtexKeyGenerator.java | 27 ++++++++++--------- .../BibtexKeyPatternPreferences.java | 26 +++++++++++++----- .../bibtexkeypattern/BracketedPattern.java | 18 +++++-------- .../importer/fileformat/EndnoteImporter.java | 3 +-- .../jabref/logic/integrity/FieldCheckers.java | 7 +++-- .../logic/integrity/IntegrityCheck.java | 4 --- .../integrity/ValidBibtexKeyChecker.java | 3 ++- .../preferences/GeneralPreferences.java | 7 ----- .../jabref/preferences/JabRefPreferences.java | 15 +++++------ .../preferences/PreferencesService.java | 2 +- src/main/resources/l10n/JabRef_en.properties | 4 +-- 20 files changed, 71 insertions(+), 70 deletions(-) diff --git a/src/main/java/org/jabref/gui/customizefields/CustomizeGeneralFieldsDialogViewModel.java b/src/main/java/org/jabref/gui/customizefields/CustomizeGeneralFieldsDialogViewModel.java index 6db4f644388..d4831f6e280 100644 --- a/src/main/java/org/jabref/gui/customizefields/CustomizeGeneralFieldsDialogViewModel.java +++ b/src/main/java/org/jabref/gui/customizefields/CustomizeGeneralFieldsDialogViewModel.java @@ -6,6 +6,7 @@ import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; +import org.jabref.Globals; import org.jabref.gui.DialogService; import org.jabref.logic.bibtexkeypattern.BibtexKeyGenerator; import org.jabref.logic.l10n.Localization; @@ -57,7 +58,7 @@ public void saveFields() { return; } - String testString = BibtexKeyGenerator.cleanKey(parts[1]); + String testString = BibtexKeyGenerator.cleanKey(parts[1], Globals.prefs.get(JabRefPreferences.DEFAULT_UNWANTED_BIBTEX_KEY_CHARACTERS)); if (!testString.equals(parts[1]) || (parts[1].indexOf('&') >= 0)) { String title = Localization.lang("Error"); String content = Localization.lang("Field names are not allowed to contain white space or the following " diff --git a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java index 77c02ef2e2d..e68d9408e55 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java +++ b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java @@ -49,7 +49,6 @@ public static FieldEditorFX getForField(final Field field, databaseContext, preferences.getFilePreferences(), journalAbbreviationRepository, - preferences.getBoolean(JabRefPreferences.ENFORCE_LEGAL_BIBTEX_KEY), preferences.getBoolean(JabRefPreferences.ALLOW_INTEGER_EDITION_BIBTEX)); final boolean isSingleLine = FieldFactory.isSingleLineField(field); diff --git a/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java b/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java index a5a9fe324b6..39f23b654ee 100644 --- a/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java +++ b/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java @@ -45,7 +45,6 @@ public void execute() { Globals.prefs.getFilePreferences(), Globals.prefs.getBibtexKeyPatternPreferences(), Globals.journalAbbreviationLoader.getRepository(Globals.prefs.getJournalAbbreviationPreferences()), - Globals.prefs.getBoolean(JabRefPreferences.ENFORCE_LEGAL_BIBTEX_KEY), Globals.prefs.getBoolean(JabRefPreferences.ALLOW_INTEGER_EDITION_BIBTEX)); Task> task = new Task<>() { diff --git a/src/main/java/org/jabref/gui/preferences/BibtexKeyPatternTab.fxml b/src/main/java/org/jabref/gui/preferences/BibtexKeyPatternTab.fxml index fef824f86b5..f79f97e4a7d 100644 --- a/src/main/java/org/jabref/gui/preferences/BibtexKeyPatternTab.fxml +++ b/src/main/java/org/jabref/gui/preferences/BibtexKeyPatternTab.fxml @@ -49,6 +49,11 @@ + + +