From daa09ffb1e2654cc77c0fc178e021d1f8375bcab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 15:23:48 +0100 Subject: [PATCH 1/9] Bump actions/checkout from 2 to 3 (#8542) Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/check-links.yaml | 2 +- .github/workflows/deployment.yml | 4 ++-- .github/workflows/gource.yml | 2 +- .github/workflows/refresh-csl-subtrees.yml | 2 +- .github/workflows/refresh-journal-lists.yml | 2 +- .github/workflows/snap.yml | 2 +- .github/workflows/tests-fetchers.yml | 2 +- .github/workflows/tests.yml | 12 ++++++------ .github/workflows/update-gradle-wrapper.yml | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/check-links.yaml b/.github/workflows/check-links.yaml index 2077d20ff80..9c0ab03ccea 100644 --- a/.github/workflows/check-links.yaml +++ b/.github/workflows/check-links.yaml @@ -13,7 +13,7 @@ jobs: markdown-link-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: gaurav-nelson/github-action-markdown-link-check@v1 with: use-quiet-mode: 'yes' diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 1a8d92e0878..8f00ffbf375 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -51,7 +51,7 @@ jobs: name: Create installer and portable version for ${{ matrix.displayName }} steps: - name: Fetch all history for all tags and branches - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Install GitVersion @@ -152,7 +152,7 @@ jobs: env: BUILDJABREFPRIVATEKEY: ${{ secrets.buildJabRefPrivateKey }} - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Fetch all history for all tags and branches run: git fetch --prune --unshallow - name: Install GitVersion diff --git a/.github/workflows/gource.yml b/.github/workflows/gource.yml index bf04acc1d4c..253ef9702a8 100644 --- a/.github/workflows/gource.yml +++ b/.github/workflows/gource.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: 'Checkout' - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Determine dates diff --git a/.github/workflows/refresh-csl-subtrees.yml b/.github/workflows/refresh-csl-subtrees.yml index d7cdf3efbf1..87f0bbb35d7 100644 --- a/.github/workflows/refresh-csl-subtrees.yml +++ b/.github/workflows/refresh-csl-subtrees.yml @@ -13,7 +13,7 @@ jobs: if: github.repository == 'JabRef/jabref' steps: - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: main fetch-depth: 0 diff --git a/.github/workflows/refresh-journal-lists.yml b/.github/workflows/refresh-journal-lists.yml index eb2f9715f33..ed6f50df22c 100644 --- a/.github/workflows/refresh-journal-lists.yml +++ b/.github/workflows/refresh-journal-lists.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Fetch all history for all tags and branches - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: main persist-credentials: false diff --git a/.github/workflows/snap.yml b/.github/workflows/snap.yml index 564ad5f0971..24bdde21743 100644 --- a/.github/workflows/snap.yml +++ b/.github/workflows/snap.yml @@ -30,7 +30,7 @@ jobs: env: SNAPCRAFT_LOGIN_FILE: ${{ secrets.SNAPCRAFT_LOGIN_FILE }} - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v3 # The image relies on https://builds.jabref.org/master/JabRef-5.0-portable_linux.tar.gz^ # See snap/snapcraft.yml for details - name: Run snapcraft build diff --git a/.github/workflows/tests-fetchers.yml b/.github/workflows/tests-fetchers.yml index 7371194d9f7..5cf4d1fef3e 100644 --- a/.github/workflows/tests-fetchers.yml +++ b/.github/workflows/tests-fetchers.yml @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up JDK uses: actions/setup-java@v2 with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 226c4275064..529acdf7c64 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up JDK uses: actions/setup-java@v2 with: @@ -50,7 +50,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up JDK uses: actions/setup-java@v2 with: @@ -82,7 +82,7 @@ jobs: options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up JDK uses: actions/setup-java@v2 with: @@ -116,7 +116,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up JDK uses: actions/setup-java@v2 with: @@ -154,7 +154,7 @@ jobs: env: SNAPCRAFT_LOGIN_FILE: ${{ secrets.CODECOV_TOKEN }} - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up JDK uses: actions/setup-java@v2 with: @@ -174,5 +174,5 @@ jobs: name: "Validate Gradle Wrapper" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: gradle/wrapper-validation-action@v1 diff --git a/.github/workflows/update-gradle-wrapper.yml b/.github/workflows/update-gradle-wrapper.yml index b27c660e5cf..bed3b544fed 100644 --- a/.github/workflows/update-gradle-wrapper.yml +++ b/.github/workflows/update-gradle-wrapper.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Update Gradle Wrapper uses: gradle-update/update-gradle-wrapper-action@v1 From 3d5e0a114915eb24d63f481da011329031847aa1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 15:27:41 +0100 Subject: [PATCH 2/9] Bump archunit-junit5-engine from 0.22.0 to 0.23.1 (#8545) Bumps [archunit-junit5-engine](https://github.com/TNG/ArchUnit) from 0.22.0 to 0.23.1. - [Release notes](https://github.com/TNG/ArchUnit/releases) - [Commits](https://github.com/TNG/ArchUnit/compare/v0.22.0...v0.23.1) --- updated-dependencies: - dependency-name: com.tngtech.archunit:archunit-junit5-engine dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ca0edbe601e..b5ef5c28538 100644 --- a/build.gradle +++ b/build.gradle @@ -211,7 +211,7 @@ dependencies { testImplementation 'org.mockito:mockito-core:4.3.1' testImplementation 'org.xmlunit:xmlunit-core:2.9.0' testImplementation 'org.xmlunit:xmlunit-matchers:2.9.0' - testRuntimeOnly 'com.tngtech.archunit:archunit-junit5-engine:0.22.0' + testRuntimeOnly 'com.tngtech.archunit:archunit-junit5-engine:0.23.1' testImplementation 'com.tngtech.archunit:archunit-junit5-api:0.23.1' testImplementation "org.testfx:testfx-core:4.0.17-alpha-SNAPSHOT" testImplementation "org.testfx:testfx-junit5:4.0.17-alpha-SNAPSHOT" From 91d34c2e5f2eca4f85e06de5b5459cf8349a4a46 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 15:44:19 +0100 Subject: [PATCH 3/9] Bump richtextfx from 0.10.7 to 0.10.9 (#8547) Bumps [richtextfx](https://github.com/FXMisc/RichTextFX) from 0.10.7 to 0.10.9. - [Release notes](https://github.com/FXMisc/RichTextFX/releases) - [Changelog](https://github.com/FXMisc/RichTextFX/blob/master/CHANGELOG.md) - [Commits](https://github.com/FXMisc/RichTextFX/compare/v0.10.7...v0.10.9) --- updated-dependencies: - dependency-name: org.fxmisc.richtext:richtextfx dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b5ef5c28538..072c6c4ff86 100644 --- a/build.gradle +++ b/build.gradle @@ -168,7 +168,7 @@ dependencies { implementation 'de.saxsys:mvvmfx:1.8.0' implementation 'com.tobiasdiez:easybind:2.2' implementation 'org.fxmisc.flowless:flowless:0.6.8' - implementation 'org.fxmisc.richtext:richtextfx:0.10.7' + implementation 'org.fxmisc.richtext:richtextfx:0.10.9' implementation group: 'org.glassfish.hk2.external', name: 'jakarta.inject', version: '2.6.1' implementation 'com.jfoenix:jfoenix:9.0.10' implementation 'org.controlsfx:controlsfx:11.1.1' From f76e7255af002f131737c26310c4605eb923da35 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 15:46:53 +0100 Subject: [PATCH 4/9] Bump postgresql from 42.3.2 to 42.3.3 (#8546) Bumps [postgresql](https://github.com/pgjdbc/pgjdbc) from 42.3.2 to 42.3.3. - [Release notes](https://github.com/pgjdbc/pgjdbc/releases) - [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md) - [Commits](https://github.com/pgjdbc/pgjdbc/compare/REL42.3.2...REL42.3.3) --- updated-dependencies: - dependency-name: org.postgresql:postgresql dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 072c6c4ff86..58eb8a409a3 100644 --- a/build.gradle +++ b/build.gradle @@ -147,7 +147,7 @@ dependencies { implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.7.5' - implementation 'org.postgresql:postgresql:42.3.2' + implementation 'org.postgresql:postgresql:42.3.3' implementation ('com.oracle.ojdbc:ojdbc10:19.3.0.0') { // causing module issues From 40636f4fc564fbaa8e5a4b9cd888130bbc982bb5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 16:08:44 +0100 Subject: [PATCH 5/9] Bump org.beryx.jlink from 2.24.4 to 2.25.0 (#8548) Bumps org.beryx.jlink from 2.24.4 to 2.25.0. --- updated-dependencies: - dependency-name: org.beryx.jlink dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 58eb8a409a3..98b6864c17b 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ plugins { id 'org.openjfx.javafxplugin' version '0.0.12' - id 'org.beryx.jlink' version '2.24.4' + id 'org.beryx.jlink' version '2.25.0' // nicer test outputs during running and completion // Homepage: https://github.com/radarsh/gradle-test-logger-plugin From 3c381bb89b3489f52ee8808616d6a572b11cca17 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 16:10:00 +0100 Subject: [PATCH 6/9] Bump guava from 31.0.1-jre to 31.1-jre (#8543) Bumps [guava](https://github.com/google/guava) from 31.0.1-jre to 31.1-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 98b6864c17b..266ecf71927 100644 --- a/build.gradle +++ b/build.gradle @@ -154,7 +154,7 @@ dependencies { exclude module: 'oraclepki' } - implementation ('com.google.guava:guava:31.0.1-jre') { + implementation ('com.google.guava:guava:31.1-jre') { // TODO: Remove this as soon as https://github.com/google/guava/issues/2960 is fixed exclude module: "jsr305" } From b304feb100391cba8792a14cdbbb8267ca7824ef Mon Sep 17 00:00:00 2001 From: Insomniac66 <35657048+Insomniac66@users.noreply.github.com> Date: Mon, 7 Mar 2022 22:13:18 +0100 Subject: [PATCH 7/9] Support two argument form of \abx@aux@cite macro in DefaultAuxParser (#8549) --- CHANGELOG.md | 1 + .../logic/auxparser/DefaultAuxParser.java | 4 +-- .../jabref/logic/auxparser/AuxParserTest.java | 27 +++++++++++++++++++ .../logic/auxparser/papertwoargmacro.aux | 8 ++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 src/test/resources/org/jabref/logic/auxparser/papertwoargmacro.aux diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fcf5c6dea6..8239749520a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where "Copy DOI url" in the right-click menu of the Entry List would just copy the DOI and not the DOI url. [#8389](https://github.com/JabRef/jabref/issues/8389) - We fixed an issue where opening the console from the drop-down menu would cause an exception. [#8466](https://github.com/JabRef/jabref/issues/8466) - We fixed an issue where pasting a URL was replacing + signs by spaces making the URL unreachable. [#8448](https://github.com/JabRef/jabref/issues/8448) +- We fixed an issue where creating subsidiary files from aux files created with some versions of biblatex would produce incorrect results. [#8513](https://github.com/JabRef/jabref/issues/8513) ### Removed diff --git a/src/main/java/org/jabref/logic/auxparser/DefaultAuxParser.java b/src/main/java/org/jabref/logic/auxparser/DefaultAuxParser.java index 8e391226575..68c80974aa4 100644 --- a/src/main/java/org/jabref/logic/auxparser/DefaultAuxParser.java +++ b/src/main/java/org/jabref/logic/auxparser/DefaultAuxParser.java @@ -32,7 +32,7 @@ public class DefaultAuxParser implements AuxParser { private static final Logger LOGGER = LoggerFactory.getLogger(DefaultAuxParser.class); - private static final Pattern CITE_PATTERN = Pattern.compile("\\\\(citation|abx@aux@cite)\\{(.+)\\}"); + private static final Pattern CITE_PATTERN = Pattern.compile("\\\\(citation|abx@aux@cite)(\\{\\d+\\})?\\{(?.+)\\}"); private static final Pattern INPUT_PATTERN = Pattern.compile("\\\\@input\\{(.+)\\}"); private final BibDatabase masterDatabase; @@ -108,7 +108,7 @@ private void matchCitation(AuxParserResult result, String line) { Matcher citeMatch = CITE_PATTERN.matcher(line); while (citeMatch.find()) { - String keyString = citeMatch.group(2); + String keyString = citeMatch.group("citationkey"); String[] keys = keyString.split(","); for (String key : keys) { diff --git a/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java b/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java index e171fb56ccd..7b1ecb29e4f 100644 --- a/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java +++ b/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java @@ -64,6 +64,33 @@ void testNormal() throws URISyntaxException, IOException { } } + @Test + void testTwoArgMacro() throws URISyntaxException, IOException { + // Result should be identical to that of testNormal + + InputStream originalStream = AuxParserTest.class.getResourceAsStream("origin.bib"); + Path auxFile = Path.of(AuxParserTest.class.getResource("papertwoargmacro.aux").toURI()); + try (InputStreamReader originalReader = new InputStreamReader(originalStream, StandardCharsets.UTF_8)) { + ParserResult result = new BibtexParser(importFormatPreferences, new DummyFileUpdateMonitor()).parse(originalReader); + + AuxParser auxParser = new DefaultAuxParser(result.getDatabase()); + AuxParserResult auxResult = auxParser.parse(auxFile); + + assertTrue(auxResult.getGeneratedBibDatabase().hasEntries()); + assertEquals(0, auxResult.getUnresolvedKeysCount()); + BibDatabase newDB = auxResult.getGeneratedBibDatabase(); + List newEntries = newDB.getEntries(); + assertEquals(2, newEntries.size()); + assertTrue(newEntries.get(0).hasChanged()); + assertTrue(newEntries.get(1).hasChanged()); + assertEquals(2, auxResult.getResolvedKeysCount()); + assertEquals(2, auxResult.getFoundKeysInAux()); + assertEquals(auxResult.getFoundKeysInAux() + auxResult.getCrossRefEntriesCount(), + auxResult.getResolvedKeysCount() + auxResult.getUnresolvedKeysCount()); + assertEquals(0, auxResult.getCrossRefEntriesCount()); + } + } + @Test void testNotAllFound() throws URISyntaxException, IOException { InputStream originalStream = AuxParserTest.class.getResourceAsStream("origin.bib"); diff --git a/src/test/resources/org/jabref/logic/auxparser/papertwoargmacro.aux b/src/test/resources/org/jabref/logic/auxparser/papertwoargmacro.aux new file mode 100644 index 00000000000..347f3f78480 --- /dev/null +++ b/src/test/resources/org/jabref/logic/auxparser/papertwoargmacro.aux @@ -0,0 +1,8 @@ +\relax +\abx@aux@cite{0}{Darwin1888} +\abx@aux@cite{0}{Einstein1920} +\bibstyle{plain} +\bibdata{origin} +\bibcite{Darwin1888}{1} +\bibcite{Einstein1920}{2} +\@writefile{toc}{\contentsline {section}{\numberline {1}}{1}} From 3c247ff55708970d857dda8ac5e0472265466435 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 7 Mar 2022 22:33:48 +0100 Subject: [PATCH 8/9] Add some JavaDoc to Fetchers --- .../jabref/logic/importer/EntryBasedFetcher.java | 2 +- .../org/jabref/logic/importer/IdBasedFetcher.java | 1 + .../jabref/logic/importer/SearchBasedFetcher.java | 3 +++ .../logic/importer/SearchBasedParserFetcher.java | 15 ++++++++++++++- .../importer/fileformat/ACMPortalParser.java | 4 ++-- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/logic/importer/EntryBasedFetcher.java b/src/main/java/org/jabref/logic/importer/EntryBasedFetcher.java index a85c8468060..781a0ed6288 100644 --- a/src/main/java/org/jabref/logic/importer/EntryBasedFetcher.java +++ b/src/main/java/org/jabref/logic/importer/EntryBasedFetcher.java @@ -6,7 +6,7 @@ /** * Searches web resources for bibliographic information based on a {@link BibEntry}. - * Useful to complete an existing entry with fetched information. + * Useful to complete an existing entry with fetched information. * May return multiple search hits. */ public interface EntryBasedFetcher extends WebFetcher { diff --git a/src/main/java/org/jabref/logic/importer/IdBasedFetcher.java b/src/main/java/org/jabref/logic/importer/IdBasedFetcher.java index 0238ef6b89a..62caee59199 100644 --- a/src/main/java/org/jabref/logic/importer/IdBasedFetcher.java +++ b/src/main/java/org/jabref/logic/importer/IdBasedFetcher.java @@ -6,6 +6,7 @@ /** * Searches web resources for bibliographic information based on an identifier. + * Examples are ISBN numbers and DOIs. */ public interface IdBasedFetcher extends WebFetcher { diff --git a/src/main/java/org/jabref/logic/importer/SearchBasedFetcher.java b/src/main/java/org/jabref/logic/importer/SearchBasedFetcher.java index 8e3e3d75533..34858548f7e 100644 --- a/src/main/java/org/jabref/logic/importer/SearchBasedFetcher.java +++ b/src/main/java/org/jabref/logic/importer/SearchBasedFetcher.java @@ -15,6 +15,9 @@ /** * Searches web resources for bibliographic information based on a free-text query. * May return multiple search hits. + *

+ * This interface is used for web resources which directly return BibTeX data ({@link BibEntry}) + *

*/ public interface SearchBasedFetcher extends WebFetcher { diff --git a/src/main/java/org/jabref/logic/importer/SearchBasedParserFetcher.java b/src/main/java/org/jabref/logic/importer/SearchBasedParserFetcher.java index 9aadba697b9..808b1b57988 100644 --- a/src/main/java/org/jabref/logic/importer/SearchBasedParserFetcher.java +++ b/src/main/java/org/jabref/logic/importer/SearchBasedParserFetcher.java @@ -13,12 +13,25 @@ import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; /** - * Provides a convenient interface for search-based fetcher, which follow the usual three-step procedure: + * Provides a convenient interface for search-based fetcher, which follows the usual three-step procedure: *
    *
  1. Open a URL based on the search query
  2. *
  3. Parse the response to get a list of {@link BibEntry}
  4. *
  5. Post-process fetched entries
  6. *
+ *

+ * This interface is used for web resources which do NOT provide BibTeX data (@link {@link BibEntry)}. + * JabRef's infrastructure to convert arbitrary input data to BibTeX is {@link Parser}. + *

+ *

+ * This interface inherits {@link SearchBasedFetcher}, because the methods performSearch have to be provided by both. + * As non-BibTeX web fetcher one could do "magic" stuff without this helper interface and directly use {@link WebFetcher}, but this is more work. + *

+ *

+ * Note that this interface "should" be an abstract class. + * However, Java does not support multi inheritance with classes (but with interfaces). + * We need multi inheritance, because a fetcher might implement multiple query types (such as id fetching {@link IdBasedFetcher)}, complete entry {@link EntryBasedFetcher}, and search-based fetcher (this class). + *

*/ public interface SearchBasedParserFetcher extends SearchBasedFetcher { diff --git a/src/main/java/org/jabref/logic/importer/fileformat/ACMPortalParser.java b/src/main/java/org/jabref/logic/importer/fileformat/ACMPortalParser.java index 0e46e834134..9a345ec595a 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/ACMPortalParser.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/ACMPortalParser.java @@ -71,8 +71,8 @@ public List parseDoiSearchPage(InputStream stream) throws ParseException Elements doiHrefs = doc.select("div.issue-item__content-right > h5 > span > a"); for (Element elem : doiHrefs) { - String fullSegement = elem.attr("href"); - String doi = fullSegement.substring(fullSegement.indexOf("10")); + String fullSegment = elem.attr("href"); + String doi = fullSegment.substring(fullSegment.indexOf("10")); doiList.add(doi); } } catch (IOException ex) { From 0c439de3d94a3e85291f51be174a529c3985602e Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 7 Mar 2022 22:58:34 +0100 Subject: [PATCH 9/9] Fix online link detection in entry editor (#8514) * Fix online link detection in entry editor * add changelog * Fix typo * update linked file * fix test * remove check for colon * fix checkstyle * fix checkstyle javadoc Co-authored-by: Oliver Kopp --- CHANGELOG.md | 1 + .../importer/SearchBasedParserFetcher.java | 4 ++-- .../org/jabref/model/entry/LinkedFile.java | 6 +++++- .../importer/util/FileFieldParserTest.java | 19 ++++++++++++++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8239749520a..d33d741c353 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Fixed +- We fixed an issue where online links in the file field were not detected correctly and could produce an exception [#8150](https://github.com/JabRef/jabref/issues/8510) - We fixed an issue where an exception could occur when saving the preferences [#7614](https://github.com/JabRef/jabref/issues/7614) - We fixed an issue where "Copy DOI url" in the right-click menu of the Entry List would just copy the DOI and not the DOI url. [#8389](https://github.com/JabRef/jabref/issues/8389) - We fixed an issue where opening the console from the drop-down menu would cause an exception. [#8466](https://github.com/JabRef/jabref/issues/8466) diff --git a/src/main/java/org/jabref/logic/importer/SearchBasedParserFetcher.java b/src/main/java/org/jabref/logic/importer/SearchBasedParserFetcher.java index 808b1b57988..1d9c2882acf 100644 --- a/src/main/java/org/jabref/logic/importer/SearchBasedParserFetcher.java +++ b/src/main/java/org/jabref/logic/importer/SearchBasedParserFetcher.java @@ -20,7 +20,7 @@ *
  • Post-process fetched entries
  • * *

    - * This interface is used for web resources which do NOT provide BibTeX data (@link {@link BibEntry)}. + * This interface is used for web resources which do NOT provide BibTeX data {@link BibEntry}. * JabRef's infrastructure to convert arbitrary input data to BibTeX is {@link Parser}. *

    *

    @@ -30,7 +30,7 @@ *

    * Note that this interface "should" be an abstract class. * However, Java does not support multi inheritance with classes (but with interfaces). - * We need multi inheritance, because a fetcher might implement multiple query types (such as id fetching {@link IdBasedFetcher)}, complete entry {@link EntryBasedFetcher}, and search-based fetcher (this class). + * We need multi inheritance, because a fetcher might implement multiple query types (such as id fetching {@link IdBasedFetcher}), complete entry {@link EntryBasedFetcher}, and search-based fetcher (this class). *

    */ public interface SearchBasedParserFetcher extends SearchBasedFetcher { diff --git a/src/main/java/org/jabref/model/entry/LinkedFile.java b/src/main/java/org/jabref/model/entry/LinkedFile.java index 63907ee01a5..158336c7a53 100644 --- a/src/main/java/org/jabref/model/entry/LinkedFile.java +++ b/src/main/java/org/jabref/model/entry/LinkedFile.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.regex.Pattern; import javafx.beans.Observable; import javafx.beans.property.SimpleStringProperty; @@ -26,6 +27,9 @@ */ public class LinkedFile implements Serializable { + private static final String REGEX_URL = "^((?:https?\\:\\/\\/|www\\.)(?:[-a-z0-9]+\\.)*[-a-z0-9]+.*)"; + private static final Pattern URL_PATTERN = Pattern.compile(REGEX_URL); + private static final LinkedFile NULL_OBJECT = new LinkedFile("", Path.of(""), ""); // We have to mark these properties as transient because they can't be serialized directly @@ -145,7 +149,7 @@ private void readObject(ObjectInputStream in) throws IOException { */ public static boolean isOnlineLink(String toCheck) { String normalizedFilePath = toCheck.trim().toLowerCase(); - return normalizedFilePath.startsWith("http://") || normalizedFilePath.startsWith("https://") || normalizedFilePath.contains("www."); + return URL_PATTERN.matcher(normalizedFilePath).matches(); } @Override diff --git a/src/test/java/org/jabref/logic/importer/util/FileFieldParserTest.java b/src/test/java/org/jabref/logic/importer/util/FileFieldParserTest.java index 4ccf9a150b6..cfe53630acb 100644 --- a/src/test/java/org/jabref/logic/importer/util/FileFieldParserTest.java +++ b/src/test/java/org/jabref/logic/importer/util/FileFieldParserTest.java @@ -138,17 +138,34 @@ private static Stream stringsToParseTestData() throws Exception { "desc:file.pdf:PDF:asdf" ), + // www inside filename + Arguments.of( + Collections.singletonList(new LinkedFile("", Path.of("/home/www.google.de.pdf"), "")), + ":/home/www.google.de.pdf" + ), + // url Arguments.of( Collections.singletonList(new LinkedFile(new URL("https://books.google.de/"), "")), "https://books.google.de/" ), + // url with www + Arguments.of( + Collections.singletonList(new LinkedFile(new URL("https://www.google.de/"), "")), + "https://www.google.de/" + ), + // url as file Arguments.of( Collections.singletonList(new LinkedFile("", new URL("http://ceur-ws.org/Vol-438"), "URL")), ":http\\://ceur-ws.org/Vol-438:URL" - ) + ), + // url as file with desc + Arguments.of( + Collections.singletonList(new LinkedFile("desc", new URL("http://ceur-ws.org/Vol-438"), "URL")), + "desc:http\\://ceur-ws.org/Vol-438:URL" + ) ); }