From 0313b4e77f94ebeaa2b3cf2e078c6f43c24d2872 Mon Sep 17 00:00:00 2001 From: Chelsey Ong Date: Sun, 3 Mar 2019 18:37:51 +0700 Subject: [PATCH 1/8] Clean key in BracketedPattern after author value is retrieved --- .../logic/bibtexkeypattern/BibtexKeyGenerator.java | 2 +- .../logic/bibtexkeypattern/BracketedPattern.java | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java index ff61a9035da..ffea572e61e 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java @@ -123,7 +123,7 @@ public String generateKey(BibEntry entry) { List parts = parseFieldMarker(typeListEntry); Character delimiter = bibtexKeyPatternPreferences.getKeywordDelimiter(); String pattern = "[" + parts.get(0) + "]"; - String label = expandBrackets(pattern, delimiter, entry, database); + String label = expandBrackets(pattern, delimiter, entry, database, bibtexKeyPatternPreferences.isEnforceLegalKey()); // apply modifier if present if (parts.size() > 1) { label = applyModifiers(label, parts, 1); diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java index f88e98b3842..7c8114613e7 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java @@ -92,6 +92,10 @@ public String expand(BibEntry bibentry, Character keywordDelimiter, BibDatabase return expandBrackets(this.pattern, keywordDelimiter, bibentry, database); } + public static String expandBrackets(String pattern, Character keywordDelimiter, BibEntry entry, BibDatabase database) { + return expandBrackets(pattern, keywordDelimiter, entry, database, false); + } + /** * Expands a pattern * @@ -101,7 +105,7 @@ public String expand(BibEntry bibentry, Character keywordDelimiter, BibDatabase * @param database The database for field resolving. May be null. * @return The expanded pattern. Not null. */ - public static String expandBrackets(String pattern, Character keywordDelimiter, BibEntry entry, BibDatabase database) { + public static String expandBrackets(String pattern, Character keywordDelimiter, BibEntry entry, BibDatabase database, boolean isEnforceLegalKey) { Objects.requireNonNull(pattern); Objects.requireNonNull(entry); StringBuilder sb = new StringBuilder(); @@ -122,10 +126,10 @@ public static String expandBrackets(String pattern, Character keywordDelimiter, // check whether there is a modifier on the end such as // ":lower": if (fieldParts.size() <= 1) { - sb.append(getFieldValue(entry, token, keywordDelimiter, database)); + sb.append(getFieldValue(entry, token, keywordDelimiter, database, isEnforceLegalKey)); } else { // apply modifiers: - String fieldValue = getFieldValue(entry, fieldParts.get(0), keywordDelimiter, database); + String fieldValue = getFieldValue(entry, fieldParts.get(0), keywordDelimiter, database, isEnforceLegalKey); sb.append(applyModifiers(fieldValue, fieldParts, 1)); } // Fetch and discard the closing ']' @@ -156,7 +160,7 @@ public static String expandBrackets(String pattern, Character keywordDelimiter, * * @return String containing the evaluation result. Empty string if the pattern cannot be resolved. */ - public static String getFieldValue(BibEntry entry, String value, Character keywordDelimiter, BibDatabase database) { + public static String getFieldValue(BibEntry entry, String value, Character keywordDelimiter, BibDatabase database, boolean isEnforceLegalKey) { String val = value; try { @@ -187,7 +191,7 @@ public static String getFieldValue(BibEntry entry, String value, Character keywo } } } - + authString = BibtexKeyGenerator.cleanKey(authString, isEnforceLegalKey); // Gather all author-related checks, so we don't // have to check all the time. if ("auth".equals(val)) { From 7d8de04a6af8f8e556c7735376bed94ae63fb304 Mon Sep 17 00:00:00 2001 From: Chelsey Ong Date: Sun, 3 Mar 2019 22:44:48 +0700 Subject: [PATCH 2/8] Shift cleaning of authString to authN only --- .../org/jabref/logic/bibtexkeypattern/BracketedPattern.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java index 7c8114613e7..12d9a1d93bb 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java @@ -191,7 +191,7 @@ public static String getFieldValue(BibEntry entry, String value, Character keywo } } } - authString = BibtexKeyGenerator.cleanKey(authString, isEnforceLegalKey); + // Gather all author-related checks, so we don't // have to check all the time. if ("auth".equals(val)) { @@ -231,6 +231,7 @@ else if ("authorLast".equals(val)) { // authN. First N chars of the first author's last // name. + authString = BibtexKeyGenerator.cleanKey(authString, isEnforceLegalKey); String fa = firstAuthor(authString); int num = Integer.parseInt(val.substring(4)); if (num > fa.length()) { From fa73ea0246d75077a4fe20b73c4bfaa077645d00 Mon Sep 17 00:00:00 2001 From: Chelsey Ong Date: Fri, 8 Mar 2019 09:37:08 +0700 Subject: [PATCH 3/8] Extract authN method --- .../bibtexkeypattern/BracketedPattern.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java index 12d9a1d93bb..36e11757552 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java @@ -228,16 +228,8 @@ else if ("authorLast".equals(val)) { return authNofMth(authString, Integer.parseInt(nums[0]), Integer.parseInt(nums[1])); } else if (val.matches("auth\\d+")) { - // authN. First N chars of the first author's last - // name. - - authString = BibtexKeyGenerator.cleanKey(authString, isEnforceLegalKey); - String fa = firstAuthor(authString); int num = Integer.parseInt(val.substring(4)); - if (num > fa.length()) { - num = fa.length(); - } - return fa.substring(0, num); + return authN(authString, num, isEnforceLegalKey); } else if (val.matches("authors\\d+")) { return nAuthors(authString, Integer.parseInt(val.substring(7))); } else { @@ -845,6 +837,18 @@ 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.cleanKey(authString, isEnforceLegalKey); + String fa = firstAuthor(authString); + if (num > fa.length()) { + num = fa.length(); + } + return fa.substring(0, num); + } + /** * authshort format: * added by Kolja Brix, kbx@users.sourceforge.net From 03fc076324c4d57e40a663f962d050bafac15f08 Mon Sep 17 00:00:00 2001 From: Chelsey Ong Date: Sun, 10 Mar 2019 09:56:14 +0800 Subject: [PATCH 4/8] Filter unwanted characters before removing whitespaces --- .../logic/bibtexkeypattern/BibtexKeyGenerator.java | 10 +++++++--- .../logic/bibtexkeypattern/BracketedPattern.java | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java index ffea572e61e..35b4c5f6524 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java @@ -72,7 +72,7 @@ private static String getAppendix(int number) { } } - public static String cleanKey(String key, boolean enforceLegalKey) { + public static String filterUnwantedCharacters(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 @@ -80,7 +80,7 @@ public static String cleanKey(String key, boolean enforceLegalKey) { StringBuilder newKey = new StringBuilder(); for (int i = 0; i < key.length(); i++) { char c = key.charAt(i); - if (!Character.isWhitespace(c) && (KEY_UNWANTED_CHARACTERS.indexOf(c) == -1)) { + if (KEY_UNWANTED_CHARACTERS.indexOf(c) == -1) { newKey.append(c); } } @@ -90,7 +90,7 @@ public static String cleanKey(String key, boolean enforceLegalKey) { StringBuilder newKey = new StringBuilder(); for (int i = 0; i < key.length(); i++) { char c = key.charAt(i); - if (!Character.isWhitespace(c) && (KEY_ILLEGAL_CHARACTERS.indexOf(c) == -1)) { + if (KEY_ILLEGAL_CHARACTERS.indexOf(c) == -1) { newKey.append(c); } } @@ -100,6 +100,10 @@ public static String cleanKey(String key, boolean enforceLegalKey) { return StringUtil.replaceSpecialCharacters(newKey.toString()); } + public static String cleanKey(String key, boolean enforceLegalKey) { + return filterUnwantedCharacters(key, enforceLegalKey).replaceAll("\\s",""); + } + public String generateKey(BibEntry entry) { String key; StringBuilder stringBuilder = new StringBuilder(); diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java index 36e11757552..c6a8d292ae5 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java @@ -841,7 +841,7 @@ 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.cleanKey(authString, isEnforceLegalKey); + authString = BibtexKeyGenerator.filterUnwantedCharacters(authString, isEnforceLegalKey); String fa = firstAuthor(authString); if (num > fa.length()) { num = fa.length(); From a0219f384719159bc067e03784348662332ad8ef Mon Sep 17 00:00:00 2001 From: Chelsey Ong Date: Sun, 10 Mar 2019 10:10:01 +0800 Subject: [PATCH 5/8] Update test cases --- .../BibtexKeyGeneratorTest.java | 46 ++++++++++++------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java index 4ed5b5bb728..6c2a319c798 100644 --- a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java +++ b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java @@ -119,73 +119,73 @@ public void testMakeLabelAndCheckLegalKeys() throws ParseException { Optional entry0 = BibtexParser.singleFromString( "@ARTICLE{kohn, author={Andreas Köning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Koen", + assertEquals("Koe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Áöning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Aoen", + assertEquals("Aoe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Éöning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Eoen", + assertEquals("Eoe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Íöning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Ioen", + assertEquals("Ioe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Ĺöning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Loen", + assertEquals("Loe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Ńöning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Noen", + assertEquals("Noe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Óöning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Ooen", + assertEquals("Ooe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Ŕöning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Roen", + assertEquals("Roe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Śöning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Soen", + assertEquals("Soe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Úöning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Uoen", + assertEquals("Uoe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Ýöning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Yoen", + assertEquals("Yoe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Źöning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Zoen", + assertEquals("Zoe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); } @@ -197,31 +197,43 @@ public void testMakeLabelAndCheckLegalKeys() throws ParseException { public void testMakeLabelAndCheckLegalKeysAccentGrave() throws ParseException { Optional entry0 = BibtexParser.singleFromString( "@ARTICLE{kohn, author={Andreas Àöning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Aoen", + assertEquals("Aoe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Èöning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Eoen", + assertEquals("Eoe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Ìöning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Ioen", + assertEquals("Ioe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Òöning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Ooen", + assertEquals("Ooe", BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", new BibDatabase()), true)); entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Ùöning}, year={2000}}", importFormatPreferences, fileMonitor); - assertEquals("Uoen", + assertEquals("Uoe", + BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", + new BibDatabase()), true)); + + entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Oraib Al-Ketan}, year={2000}}", + importFormatPreferences, fileMonitor); + assertEquals("AlK", + BibtexKeyGenerator.cleanKey(BibtexKeyGenerator.generateKey(entry0.get(), "auth3", + new BibDatabase()), true)); + + 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)); } From 89a398b5951659d11e81aa4ad9979deb0150ffc2 Mon Sep 17 00:00:00 2001 From: Chelsey Ong Date: Sun, 10 Mar 2019 10:10:30 +0800 Subject: [PATCH 6/8] Remove -s from key --- .../org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java | 4 ++-- 1 file changed, 2 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 35b4c5f6524..f1a7306b558 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java @@ -26,8 +26,8 @@ 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_UNWANTED_CHARACTERS = "{}(),\\\""; + private static final String KEY_ILLEGAL_CHARACTERS = "{}(),\\\"-#~^':`"; + private static final String KEY_UNWANTED_CHARACTERS = "{}(),\\\"-"; private final AbstractBibtexKeyPattern citeKeyPattern; private final BibDatabase database; private final BibtexKeyPatternPreferences bibtexKeyPatternPreferences; From e3e696113b1877d856abbcfbaf80ef04a0ca77b2 Mon Sep 17 00:00:00 2001 From: Chelsey Ong Date: Sun, 10 Mar 2019 10:36:33 +0800 Subject: [PATCH 7/8] Remove the dashes from test case --- .../logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java b/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java index a28d412bc35..88345234b72 100644 --- a/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java +++ b/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java @@ -397,7 +397,7 @@ void generateKeyTitleRegexe() { bibtexKeyPattern.setDefaultValue("[title:regex(\" \",\"-\")]"); entry.setField("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 f414a9643f519e12553328ef9c00fd51e15fb7dc Mon Sep 17 00:00:00 2001 From: Chelsey Ong Date: Sun, 10 Mar 2019 18:18:21 +0800 Subject: [PATCH 8/8] Rename method to removeUnwantedCharacters --- .../org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java | 4 ++-- .../org/jabref/logic/bibtexkeypattern/BracketedPattern.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java index f1a7306b558..6e10ac5ff8f 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGenerator.java @@ -72,7 +72,7 @@ private static String getAppendix(int number) { } } - public static String filterUnwantedCharacters(String key, boolean enforceLegalKey) { + 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 @@ -101,7 +101,7 @@ public static String filterUnwantedCharacters(String key, boolean enforceLegalKe } public static String cleanKey(String key, boolean enforceLegalKey) { - return filterUnwantedCharacters(key, enforceLegalKey).replaceAll("\\s",""); + return removeUnwantedCharacters(key, enforceLegalKey).replaceAll("\\s",""); } public String generateKey(BibEntry entry) { diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java index c6a8d292ae5..25f214ab164 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java @@ -841,7 +841,7 @@ 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.filterUnwantedCharacters(authString, isEnforceLegalKey); + authString = BibtexKeyGenerator.removeUnwantedCharacters(authString, isEnforceLegalKey); String fa = firstAuthor(authString); if (num > fa.length()) { num = fa.length();