Skip to content

Commit

Permalink
Fix do not clear wanted special characters (#4770)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-kilian authored and LinusDietz committed Mar 26, 2019
1 parent e14b567 commit 8e6b177
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where only one PDF file could be imported [#4422](https://github.com/JabRef/jabref/issues/4422)
- We fixed an issue where "Move to group" would always move the first entry in the library and not the selected [#4414](https://github.com/JabRef/jabref/issues/4414)
- We fixed an issue where an older dialog appears when downloading full texts from the quality menu. [#4489](https://github.com/JabRef/jabref/issues/4489)

- We fixed an issue where special characters where removed from non label key generation pattern parts [#4767](https://github.com/JabRef/jabref/issues/4767)



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ public String generateKey(BibEntry entry) {
label = applyModifiers(label, parts, 1);
}

// Remove all illegal characters from the label.
label = cleanKey(label, bibtexKeyPatternPreferences.isEnforceLegalKey());

stringBuilder.append(label);

} else {
Expand All @@ -143,8 +146,7 @@ public String generateKey(BibEntry entry) {
LOGGER.warn("Cannot make label", e);
}

// Remove all illegal characters from the key.
key = cleanKey(stringBuilder.toString(), bibtexKeyPatternPreferences.isEnforceLegalKey());
key = stringBuilder.toString();

// Remove Regular Expressions while generating Keys
String regex = bibtexKeyPatternPreferences.getKeyPatternRegex();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1073,4 +1073,12 @@ public void generateKeyWithYearAuthUpperTitleSentenceCaseModifier() throws Excep
assertEquals("NewtonMaxwellEtAl_2019_TheInterestingTitleLongerThanThreeWords", BibtexKeyGenerator.generateKey(entry, "[authors2]_[year]_[title:capitalize]"));
}

@Test
public void generateKeyWithMinusInCitationStyleOutsideAField() throws Exception {
BibEntry entry = new BibEntry();
entry.setField("author", AUTHOR_STRING_FIRSTNAME_FULL_LASTNAME_FULL_COUNT_1);
entry.setField("year", "2019");

assertEquals("Newton-2019", BibtexKeyGenerator.generateKey(entry, "[auth]-[year]"));
}
}

0 comments on commit 8e6b177

Please sign in to comment.