From ad9a954ea267534c6ff8baf0bb23cd4f39ce58d5 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Tue, 16 May 2023 00:12:48 +0200 Subject: [PATCH] Support for $\backslash$ in file paths --- CHANGELOG.md | 1 + .../org/jabref/logic/importer/util/FileFieldParser.java | 7 ++++++- .../jabref/logic/importer/util/FileFieldParserTest.java | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index afadd1b8aad..9dcd714a53d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We enabled scrolling in the groups list when dragging a group on another group. [#2869](https://github.com/JabRef/jabref/pull/2869) - We added the option to automatically download online files when a new entry is created from an existing ID (e.g. DOI). The option can be disabled in the preferences under "Import and Export" [#9756](https://github.com/JabRef/jabref/issues/9756) - We added a new Integrity check for unscaped ampersands. [koppor#585](https://github.com/koppor/jabref/issues/585) +- We added support for parsing `$\backslash$` in file paths (as exported by Mendeley). [forum#3470](https://discourse.jabref.org/t/mendeley-bib-import-with-linked-files/3470) - We added the possibility to automatically fetch entries when an IBSN is pasted on the main table [#9864](https://github.com/JabRef/jabref/issues/9864) ### Changed 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 7e68a3a789e..4b2804bb976 100644 --- a/src/main/java/org/jabref/logic/importer/util/FileFieldParser.java +++ b/src/main/java/org/jabref/logic/importer/util/FileFieldParser.java @@ -18,10 +18,15 @@ public class FileFieldParser { private final String value; private StringBuilder charactersOfCurrentElement; + private boolean windowsPath; public FileFieldParser(String value) { - this.value = value; + if (value == null) { + this.value = null; + } else { + this.value = value.replace("$\\backslash$", "\\"); + } } /** 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 db6de11c190..73a391fa355 100644 --- a/src/test/java/org/jabref/logic/importer/util/FileFieldParserTest.java +++ b/src/test/java/org/jabref/logic/importer/util/FileFieldParserTest.java @@ -57,6 +57,12 @@ private static Stream stringsToParseTest() throws Exception { "Desc:File.PDF:PDF" ), + // Mendeley input + Arguments.of( + Collections.singletonList(new LinkedFile("", Path.of("C:/Users/XXXXXX/AppData/Local/Mendeley Ltd./Mendeley Desktop/Downloaded/Brown - 2017 - Physical test methods for elastomers.pdf"), "pdf")), + ":C$\\backslash$:/Users/XXXXXX/AppData/Local/Mendeley Ltd./Mendeley Desktop/Downloaded/Brown - 2017 - Physical test methods for elastomers.pdf:pdf" + ), + // parseCorrectOnlineInput Arguments.of( Collections.singletonList(new LinkedFile(new URL("http://arxiv.org/pdf/2010.08497v1"), "PDF")),