Skip to content

Commit

Permalink
Fix duplicate check not taking umlauts into account
Browse files Browse the repository at this point in the history
Fixes ttps://github.com/JabRef/jabref-issue-melting-pot/issues/249
  • Loading branch information
Siedlerchr committed Jan 3, 2024
1 parent 37d0518 commit 6da8438
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
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

### 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 @@ -77,6 +77,14 @@ public void testDuplicateDetectionWithSameAuthor() {

assertTrue(duplicateChecker.isDuplicate(one, two, BibDatabaseMode.BIBTEX));
}
@Test
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() {
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

0 comments on commit 6da8438

Please sign in to comment.