diff --git a/CHANGELOG.md b/CHANGELOG.md index ba6188a264e..678f8dbf011 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/main/java/org/jabref/logic/database/DuplicateCheck.java b/src/main/java/org/jabref/logic/database/DuplicateCheck.java index 3090c9a8778..f2858bb46b7 100644 --- a/src/main/java/org/jabref/logic/database/DuplicateCheck.java +++ b/src/main/java/org/jabref/logic/database/DuplicateCheck.java @@ -154,14 +154,14 @@ private static double[] compareFieldSet(final Collection fields, final Bi } private static int compareSingleField(final Field field, final BibEntry one, final BibEntry two) { - final Optional optionalStringOne = one.getField(field); - final Optional optionalStringTwo = two.getField(field); - if (!optionalStringOne.isPresent()) { - if (!optionalStringTwo.isPresent()) { + final Optional optionalStringOne = one.getFieldLatexFree(field); + final Optional 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; } diff --git a/src/test/java/org/jabref/logic/database/DuplicateCheckTest.java b/src/test/java/org/jabref/logic/database/DuplicateCheckTest.java index 8c644ab40f2..39741898087 100644 --- a/src/test/java/org/jabref/logic/database/DuplicateCheckTest.java +++ b/src/test/java/org/jabref/logic/database/DuplicateCheckTest.java @@ -78,6 +78,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() { BibEntry one = new BibEntry(StandardEntryType.Article).withField(StandardField.AUTHOR, "Billy Bob"); diff --git a/src/test/java/org/jabref/logic/integrity/ASCIICharacterCheckerTest.java b/src/test/java/org/jabref/logic/integrity/ASCIICharacterCheckerTest.java index 09efadebe2d..9dbefceb61c 100644 --- a/src/test/java/org/jabref/logic/integrity/ASCIICharacterCheckerTest.java +++ b/src/test/java/org/jabref/logic/integrity/ASCIICharacterCheckerTest.java @@ -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)); }