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 duplicate checker does not respect umlauts / latex free fields #10744

Merged
merged 4 commits into from
Jan 3, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv

- We fixed an issue where attempting to cancel the importing/generation of an entry from id is ignored. [#10508](https://github.com/JabRef/jabref/issues/10508)
- We fixed an issue where the preview panel showing the wrong entry (an entry that is not selected in the entry table). [#9172](https://github.com/JabRef/jabref/issues/9172)
- We fixed an issue where the duplicate check did not take umlauts or other LaTeX-encoded characters into account. [#10744](https://github.com/JabRef/jabref/pull/10744)
- We fixed the colors of the icon on hover for unset special fields. [#10431](https://github.com/JabRef/jabref/issues/10431)

### Removed
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/jabref/logic/database/DuplicateCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ private static double[] compareFieldSet(final Collection<Field> fields, final Bi
}

private static int compareSingleField(final Field field, final BibEntry one, final BibEntry two) {
final Optional<String> optionalStringOne = one.getField(field);
final Optional<String> optionalStringTwo = two.getField(field);
if (!optionalStringOne.isPresent()) {
if (!optionalStringTwo.isPresent()) {
final Optional<String> optionalStringOne = one.getFieldLatexFree(field);
final Optional<String> optionalStringTwo = two.getFieldLatexFree(field);
if (optionalStringOne.isEmpty()) {
if (optionalStringTwo.isEmpty()) {
return EMPTY_IN_BOTH;
}
return EMPTY_IN_ONE;
} else if (!optionalStringTwo.isPresent()) {
} else if (optionalStringTwo.isEmpty()) {
return EMPTY_IN_TWO;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ public void testDuplicateDetectionWithSameAuthor() {
assertTrue(duplicateChecker.isDuplicate(one, two, BibDatabaseMode.BIBTEX));
}

@Test
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
public void testDuplicateDetectionWithSameAuthorAndUmlauts() {
BibEntry one = new BibEntry(StandardEntryType.Article).withField(StandardField.AUTHOR, "Billy Bobä");
BibEntry two = new BibEntry(StandardEntryType.Article).withField(StandardField.AUTHOR, "Bill{\\\"{a}} Bob{\\\"{a}}");

assertTrue(duplicateChecker.isDuplicate(one, two, BibDatabaseMode.BIBTEX));
}

@Test
public void testDuplicateDetectionWithDifferentAuthors() {
BibEntry one = new BibEntry(StandardEntryType.Article).withField(StandardField.AUTHOR, "Billy Bob");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ void fieldDoesNotAcceptUnicode() {

@Test
void fieldAcceptsOnlyAsciiCharacters() {
String field = "";
StringBuilder field = new StringBuilder();
for (int i = 32; i <= 127; i++) {
field += Character.toString(i);
field.append(Character.toString(i));
}
entry.setField(StandardField.TITLE, field);
entry.setField(StandardField.TITLE, field.toString());
assertEquals(Collections.emptyList(), checker.check(entry));
}

Expand Down