Skip to content

Commit

Permalink
Fixes Zotero file handling for absolute paths (#11038)
Browse files Browse the repository at this point in the history
* Fixes Zotero file handling for absolute paths

Fixes #10959

* checkstyle mimiimm

* fix changelog

* cannot fix
  • Loading branch information
Siedlerchr authored Mar 18, 2024
1 parent 197f730 commit fb65bed
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [#10959](https://github.com/JabRef/jabref/issues/10959)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public List<LinkedFile> parse() {
// We are at the second : (position 3 in the example) and "just" add it to the current element
charactersOfCurrentElement.append(c);
windowsPath = true;
// 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
/**
* Tests for reading whole bib files can be found at {@link org.jabref.logic.importer.fileformat.BibtexImporterTest}
* <p>
* 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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ private static Stream<Arguments> 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"
)
);
}
Expand Down

0 comments on commit fb65bed

Please sign in to comment.