Skip to content

Commit

Permalink
Fix #1381 File links containing blanks are broken if non-default view…
Browse files Browse the repository at this point in the history
…er is set
  • Loading branch information
stefan-kolb committed May 12, 2016
1 parent e988335 commit 8e6ac4d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/net/sf/jabref/gui/desktop/os/Windows.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExternalFileType> type = ExternalFileTypes.getInstance().getExternalFileTypeByExt(fileType);
Expand All @@ -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");
Expand All @@ -41,21 +37,20 @@ 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
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));
}
}

0 comments on commit 8e6ac4d

Please sign in to comment.