From f6aae339f0c7b3f36c79f2ba3d71f809206f0050 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sun, 17 Mar 2024 21:12:56 +0100 Subject: [PATCH 1/4] Fixes Zotero file handling for absolute paths Fixes #10959 --- CHANGELOG.md | 1 + .../jabref/logic/importer/util/FileFieldParser.java | 8 +++++++- .../logic/importer/fileformat/BibtexParserTest.java | 2 +- .../logic/importer/util/FileFieldParserTest.java | 10 ++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdd097ee56d..ea3535b5c94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where the `File -> Close library` menu item was not disabled when no library was open. [#10948](https://github.com/JabRef/jabref/issues/10948) - We fixed an issue where the Document Viewer would show the PDF in only half the window when maximized. [#10934](https://github.com/JabRef/jabref/issues/10934) - Clicking on the crossref and related tags in the entry editor jumps to the linked entry. [#5484](https://github.com/JabRef/jabref/issues/5484) [#9369](https://github.com/JabRef/jabref/issues/9369) +- We fixed an issue where JabRef could not parse absolute file paths from Zotero exports [#10595](https://github.com/JabRef/jabref/issues/10959) ### Removed diff --git a/src/main/java/org/jabref/logic/importer/util/FileFieldParser.java b/src/main/java/org/jabref/logic/importer/util/FileFieldParser.java index a180e51c9ad..dd27a50f066 100644 --- a/src/main/java/org/jabref/logic/importer/util/FileFieldParser.java +++ b/src/main/java/org/jabref/logic/importer/util/FileFieldParser.java @@ -102,7 +102,13 @@ public List parse() { // We are at the second : (position 3 in the example) and "just" add it to the current element charactersOfCurrentElement.append(c); windowsPath = true; - } else { + // special case for zotero absolute path on windows that do not have a colon in front + // e.g. A:\zotero\paper.pdf + } else if (charactersOfCurrentElement.length() == 1 && value.charAt(i + 1) == '\\') { + charactersOfCurrentElement.append(c); + windowsPath = true; + } + else { // We are in the next LinkedFile data element linkedFileData.add(charactersOfCurrentElement.toString()); resetDataStructuresForNextElement(); diff --git a/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java b/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java index 3c84de494c2..7a118622cfe 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java @@ -75,7 +75,7 @@ /** * Tests for reading whole bib files can be found at {@link org.jabref.logic.importer.fileformat.BibtexImporterTest} *

- * Tests cannot be executed concurrently, because Localization is used at {@link BibtexParser#sparseAndAddEntry(String)} + * Tests cannot be executed concurrently, because Localization is used at {@link BibtexParser#parseAndAddEntry(String)} */ class BibtexParserTest { private static final String BIB_DESK_ROOT_GROUP_NAME = "BibDeskGroups"; 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 1f5e1b17a43..a530aa368c0 100644 --- a/src/test/java/org/jabref/logic/importer/util/FileFieldParserTest.java +++ b/src/test/java/org/jabref/logic/importer/util/FileFieldParserTest.java @@ -203,6 +203,16 @@ private static Stream stringsToParseTest() throws Exception { Arguments.of( Collections.singletonList(new LinkedFile("", "matheus.ea explicit.pdf", "", "https://arxiv.org/pdf/1109.0517.pdf")), ":matheus.ea explicit.pdf::https\\://arxiv.org/pdf/1109.0517.pdf" + ), + // Absolute path + Arguments.of( + Collections.singletonList(new LinkedFile("", "A:\\Zotero\\storage\\test.pdf", "")), + ":A:\\Zotero\\storage\\test.pdf" + ), + // zotero absolute path + Arguments.of( + Collections.singletonList(new LinkedFile("", "A:\\Zotero\\storage\\test.pdf", "")), + "A:\\Zotero\\storage\\test.pdf" ) ); } From 69b5e6d6af98e941a342a9806379b4836849196f Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sun, 17 Mar 2024 21:17:13 +0100 Subject: [PATCH 2/4] checkstyle mimiimm --- .../java/org/jabref/logic/importer/util/FileFieldParser.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/logic/importer/util/FileFieldParser.java b/src/main/java/org/jabref/logic/importer/util/FileFieldParser.java index dd27a50f066..242671f7ea2 100644 --- a/src/main/java/org/jabref/logic/importer/util/FileFieldParser.java +++ b/src/main/java/org/jabref/logic/importer/util/FileFieldParser.java @@ -107,8 +107,7 @@ public List parse() { } else if (charactersOfCurrentElement.length() == 1 && value.charAt(i + 1) == '\\') { charactersOfCurrentElement.append(c); windowsPath = true; - } - else { + } else { // We are in the next LinkedFile data element linkedFileData.add(charactersOfCurrentElement.toString()); resetDataStructuresForNextElement(); From 5a27225cab3eb174af8262cd026272c8d7af24c5 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sun, 17 Mar 2024 21:21:53 +0100 Subject: [PATCH 3/4] fix changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea3535b5c94..59aae766a4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,7 +65,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where the `File -> Close library` menu item was not disabled when no library was open. [#10948](https://github.com/JabRef/jabref/issues/10948) - We fixed an issue where the Document Viewer would show the PDF in only half the window when maximized. [#10934](https://github.com/JabRef/jabref/issues/10934) - Clicking on the crossref and related tags in the entry editor jumps to the linked entry. [#5484](https://github.com/JabRef/jabref/issues/5484) [#9369](https://github.com/JabRef/jabref/issues/9369) -- We fixed an issue where JabRef could not parse absolute file paths from Zotero exports [#10595](https://github.com/JabRef/jabref/issues/10959) +- We fixed an issue where JabRef could not parse absolute file paths from Zotero exports [#10959](https://github.com/JabRef/jabref/issues/10959) ### Removed @@ -91,7 +91,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - Short DOI formatter now checks, if the value is already formatted. If so, it returns the value instead of calling the ShortDOIService again. [#10589](https://github.com/JabRef/jabref/issues/10589) - We upgraded to JavaFX 21.0.1. As a consequence JabRef requires now macOS 11 or later and GTK 3.8 or later on Linux [10627](https://github.com/JabRef/jabref/pull/10627). - A user-specific comment fields is not enabled by default, but can be enabled using the "Add" button. [#10424](https://github.com/JabRef/jabref/issues/10424) -- We upgraded to Lucene 9.9 for the fulltext search. The search index will be rebuild. [#10686](https://github.com/JabRef/jabref/pull/10686) +- We upgraded to Lucene 9.9 for the fulltext search. The search index will be rebuilt. [#10686](https://github.com/JabRef/jabref/pull/10686) - When using "Copy..." -> "Copy citation key", the delimiter configured at "Push applications" is respected. [#10707](https://github.com/JabRef/jabref/pull/10707) ### Fixed From 9375823c8ed5cdc0e7415b777568461d87a1d9cf Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sun, 17 Mar 2024 21:28:10 +0100 Subject: [PATCH 4/4] cannot fix --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59aae766a4f..f9f1ce0c6be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -91,7 +91,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - Short DOI formatter now checks, if the value is already formatted. If so, it returns the value instead of calling the ShortDOIService again. [#10589](https://github.com/JabRef/jabref/issues/10589) - We upgraded to JavaFX 21.0.1. As a consequence JabRef requires now macOS 11 or later and GTK 3.8 or later on Linux [10627](https://github.com/JabRef/jabref/pull/10627). - A user-specific comment fields is not enabled by default, but can be enabled using the "Add" button. [#10424](https://github.com/JabRef/jabref/issues/10424) -- We upgraded to Lucene 9.9 for the fulltext search. The search index will be rebuilt. [#10686](https://github.com/JabRef/jabref/pull/10686) +- We upgraded to Lucene 9.9 for the fulltext search. The search index will be rebuild. [#10686](https://github.com/JabRef/jabref/pull/10686) - When using "Copy..." -> "Copy citation key", the delimiter configured at "Push applications" is respected. [#10707](https://github.com/JabRef/jabref/pull/10707) ### Fixed