Skip to content

Commit

Permalink
Make Identifier paste work with Unicode REPLACEMENT CHARACTER (#12083)
Browse files Browse the repository at this point in the history
* Solved "Identifier paste should work with Unicode REPLACEMENT CHARACTER #11986"

* Style fix

* Added a CHANGELOG.md entry
  • Loading branch information
MadDingzhen authored Oct 27, 2024
1 parent f0d8632 commit ea7c2ae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue where it was not possible to select selecting content of other user's comments.[#11106](https://github.com/JabRef/jabref/issues/11106)
- We fixed an issue where web search preferences "Custom API key" table modifications not discarded. [#11925](https://github.com/JabRef/jabref/issues/11925)
- We fixed an issue where trying to open a library from a failed mounted directory on Mac would cause an error. [#10548](https://github.com/JabRef/jabref/issues/10548)
- We fixed an issue where identifier paste couldn't work with Unicode REPLACEMENT CHARACTER. [#11986](https://github.com/JabRef/jabref/issues/11986)

### Removed

Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/jabref/model/entry/identifier/DOI.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ public static boolean isValid(String doi) {
*/
public static Optional<DOI> findInText(String text) {
Optional<DOI> result = Optional.empty();
text = text.replaceAll("[�]", "");

Matcher matcher = FIND_DOI_PATT.matcher(text);
if (matcher.find()) {
Expand Down
7 changes: 6 additions & 1 deletion src/test/java/org/jabref/model/entry/identifier/DOITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,12 @@ private static Stream<Arguments> testData() {

// findDoiWithSpecialCharactersInText
Arguments.of("10.1175/1520-0493(2002)130%3C1913:EDAWPO%3E2.0.CO;2",
DOI.findInText("https://doi.org/10.1175/1520-0493(2002)130%3C1913:EDAWPO%3E2.0.CO;2").get().asString())
DOI.findInText("https://doi.org/10.1175/1520-0493(2002)130%3C1913:EDAWPO%3E2.0.CO;2").get().asString()),

// Test with Unicode replacement character
Arguments.of("10.1006/jmbi.1998.2354", DOI.findInText("other stuff �10.1006/jmbi.1998.2354").get().asString()),
Arguments.of("10.1006/jmbi.1998.2354", DOI.findInText("other stuff 10.1006/jmbi.1998.2354�").get().asString()),
Arguments.of("10/gf4gqc", DOI.findInText("other stuff �doi�:10�/gf4����gqc�").get().asString())
);
}

Expand Down

0 comments on commit ea7c2ae

Please sign in to comment.