From 8e6ac4df4e11d8df71bf2b52fb8c3ca4271410f5 Mon Sep 17 00:00:00 2001 From: Stefan Kolb Date: Thu, 12 May 2016 14:34:46 +0200 Subject: [PATCH] Fix #1381 File links containing blanks are broken if non-default viewer is set --- CHANGELOG.md | 1 + src/main/java/net/sf/jabref/gui/desktop/os/Windows.java | 9 ++------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab3b180cd20..c1eb79fb6d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ to [sourceforge feature requests](https://sourceforge.net/p/jabref/features/) by - Fixed [#1365](https://github.com/JabRef/jabref/issues/1365): Default label pattern back to "[auth][year]" - Fixed [#796](https://github.com/JabRef/jabref/issues/796): Undoing more than one entry at the same time is now working - Fixed [#1353](https://github.com/JabRef/jabref/issues/1353): Fetch-Preview did not display updated BibTeX-Key after clicking on `Generate Now` +- Fixed [#1381](https://github.com/JabRef/jabref/issues/1381): File links containing blanks are broken if non-default viewer is set ### Removed - Removed possibility to export entries/databases to an `.sql` file, as the logic cannot easily use the correct escape logic diff --git a/src/main/java/net/sf/jabref/gui/desktop/os/Windows.java b/src/main/java/net/sf/jabref/gui/desktop/os/Windows.java index 3fe266e56f0..6032435a794 100644 --- a/src/main/java/net/sf/jabref/gui/desktop/os/Windows.java +++ b/src/main/java/net/sf/jabref/gui/desktop/os/Windows.java @@ -9,10 +9,8 @@ import net.sf.jabref.external.ExternalFileTypes; public class Windows implements NativeDesktop { - private static String DEFAULT_EXECUTABLE_EXTENSION = ".exe"; - @Override public void openFile(String filePath, String fileType) throws IOException { Optional type = ExternalFileTypes.getInstance().getExternalFileTypeByExt(fileType); @@ -23,12 +21,10 @@ public void openFile(String filePath, String fileType) throws IOException { String quotePath = "\"" + filePath +"\""; Runtime.getRuntime().exec(new String[] {"explorer.exe", quotePath}); } - } @Override public String detectProgramPath(String programName, String directoryName) { - String progFiles = System.getenv("ProgramFiles(x86)"); if (progFiles == null) { progFiles = System.getenv("ProgramFiles"); @@ -41,7 +37,7 @@ public String detectProgramPath(String programName, String directoryName) { @Override public void openFileWithApplication(String filePath, String application) throws IOException { - Runtime.getRuntime().exec(Paths.get(application) + " " + Paths.get(filePath)); + new ProcessBuilder(Paths.get(application).toString(), Paths.get(filePath).toString()).start(); } @Override @@ -49,13 +45,12 @@ public void openFolderAndSelectFile(String filePath) throws IOException { String cmd = "explorer.exe"; String arg = "/select,"; String[] commandWithArgs = {cmd, arg, filePath}; - //Array variant, because otherwise the Tokenizer, which is internally run, kills the whitespaces in the path + // Array variant, because otherwise the Tokenizer, which is internally run, kills the whitespaces in the path Runtime.getRuntime().exec(commandWithArgs); } @Override public void openConsole(String absolutePath) throws IOException { - Runtime.getRuntime().exec("cmd.exe /c start", null, new File(absolutePath)); } }