Skip to content

Commit

Permalink
remove any newlines and spaces in isbn when fetching (#7023)
Browse files Browse the repository at this point in the history
* remove any newlines and spaces in isbn when fetching
Fixes #6456

* Update IsbnFetcher.java

* Update CHANGELOG.md

* remove duplicate changelog entry
  • Loading branch information
joethei authored Oct 17, 2020
1 parent 7ce9603 commit 0ef37d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ inserting new citations in a OpenOffic/LibreOffice document. [#6957](https://git
- We fixed an issue where a remove icon was shown for standard entry types in the custom entry types dialog. [#6906](https://github.com/JabRef/jabref/issues/6906)
- We fixed an issue where it was impossible to connect to OpenOffice/LibreOffice on Mac OSX. [#6970](https://github.com/JabRef/jabref/pull/6970)
- We fixed an issue with the python script used by browser plugins that failed to locate JabRef if not installed in its default location. [#6963](https://github.com/JabRef/jabref/pull/6963/files)
- We fixed an issue where spaces and newlines in an isbn would generate an exception. [#6456](https://github.com/JabRef/jabref/issues/6456)
- We fixed an issue where identity column header had incorrect foreground color in the Dark theme. [#6796](https://github.com/JabRef/jabref/issues/6796)
- We fixed an issue where clicking on Collapse All button in the Search for Unlinked Local Files expanded the directory structure erroneously [#6848](https://github.com/JabRef/jabref/issues/6848)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.regex.Pattern;

import org.jabref.logic.help.HelpFile;
import org.jabref.logic.importer.EntryBasedFetcher;
Expand All @@ -23,6 +24,7 @@
public class IsbnFetcher implements EntryBasedFetcher, IdBasedFetcher {

private static final Logger LOGGER = LoggerFactory.getLogger(IsbnFetcher.class);
private static final Pattern NEWLINE_SPACE_PATTERN = Pattern.compile("\\n|\\r\\n|\\s");
protected final ImportFormatPreferences importFormatPreferences;

public IsbnFetcher(ImportFormatPreferences importFormatPreferences) {
Expand All @@ -44,6 +46,8 @@ public Optional<BibEntry> performSearchById(String identifier) throws FetcherExc
if (StringUtil.isBlank(identifier)) {
return Optional.empty();
}
// remove any newlines and spaces.
identifier = NEWLINE_SPACE_PATTERN.matcher(identifier).replaceAll("");

IsbnViaEbookDeFetcher isbnViaEbookDeFetcher = new IsbnViaEbookDeFetcher(importFormatPreferences);
Optional<BibEntry> bibEntry = isbnViaEbookDeFetcher.performSearchById(identifier);
Expand Down

0 comments on commit 0ef37d8

Please sign in to comment.