Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix do not clear wanted special characters #4770

Merged
merged 2 commits into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]"));
}
}