diff --git a/CHANGELOG.md b/CHANGELOG.md index ac70ed8452b..4e097a40231 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We fixed an exception which occurred when an invalid jstyle was loaded. [#5452](https://github.com/JabRef/jabref/issues/5452) - We fixed an error where the preview theme did not adapt to the "Dark" mode [#5463](https://github.com/JabRef/jabref/issues/5463) - We fixed an issue where the merge dialog showed the wrong text colour in "Dark" mode [#5516](https://github.com/JabRef/jabref/issues/5516) +- We fixed an issue where the author field was not correctly parsed during bibtex key-generation. [#5551](https://github.com/JabRef/jabref/issues/5551) ### Removed diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java index 2a9d1c11b6a..a26fc93f4a8 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java @@ -843,8 +843,8 @@ public static String authNofMth(String authorField, int n, int m) { * First N chars of the first author's last name. */ public static String authN(String authString, int num, boolean isEnforceLegalKey) { - authString = BibtexKeyGenerator.removeUnwantedCharacters(authString, isEnforceLegalKey); String fa = firstAuthor(authString); + fa = BibtexKeyGenerator.removeUnwantedCharacters(fa, isEnforceLegalKey); if (num > fa.length()) { num = fa.length(); } diff --git a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java index 093cd3050e6..e3adfba04bf 100644 --- a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java +++ b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java @@ -1087,4 +1087,13 @@ public void generateKeyWithMinusInCitationStyleOutsideAField() throws Exception assertEquals("Newton-2019", BibtexKeyGenerator.generateKey(entry, "[auth]-[year]")); } + + @Test + public void generateKeyWithWithFirstNCharacters() throws Exception { + BibEntry entry = new BibEntry(); + entry.setField(StandardField.AUTHOR, "Newton, Isaac"); + entry.setField(StandardField.YEAR, "2019"); + + assertEquals("newt-2019", BibtexKeyGenerator.generateKey(entry, "[auth4:lower]-[year]")); + } }