Fix wxLaunchDefault{Application,Browser}() for arguments containing spaces

See #16581
This commit is contained in:
Paul Cornett
2017-02-18 10:17:42 -08:00
parent c64a4c3224
commit 5e7db7c0f1

View File

@@ -2660,7 +2660,11 @@ bool wxLaunchDefaultApplication(const wxString& document, int flags)
if ( wxGetEnv("PATH", &path) &&
wxFindFileInPath(&xdg_open, path, "xdg-open") )
{
if ( wxExecute(xdg_open + " " + document) )
const char* argv[3];
argv[0] = xdg_open.fn_str();
argv[1] = document.fn_str();
argv[2] = NULL;
if (wxExecute(argv))
return true;
}
@@ -2687,6 +2691,10 @@ wxDoLaunchDefaultBrowser(const wxLaunchBrowserParams& params)
#endif // GTK_CHECK_VERSION(2,14,0)
#endif // __WXGTK__
const char* argv[4];
argv[1] = params.GetPathOrURL().fn_str();
argv[2] = NULL;
// Our best best is to use xdg-open from freedesktop.org cross-desktop
// compatibility suite xdg-utils
// (see http://portland.freedesktop.org/wiki/) -- this is installed on
@@ -2697,7 +2705,8 @@ wxDoLaunchDefaultBrowser(const wxLaunchBrowserParams& params)
if ( wxGetEnv("PATH", &path) &&
wxFindFileInPath(&xdg_open, path, "xdg-open") )
{
if ( wxExecute(xdg_open + " " + params.GetPathOrURL()) )
argv[0] = xdg_open.fn_str();
if (wxExecute(argv))
return true;
}
@@ -2715,16 +2724,19 @@ wxDoLaunchDefaultBrowser(const wxLaunchBrowserParams& params)
output, errors, wxEXEC_NODISABLE );
if (res >= 0 && errors.GetCount() == 0)
{
wxString cmd = output[0];
cmd << wxT(' ') << params.GetPathOrURL();
if (wxExecute(cmd))
argv[0] = output[0].fn_str();
if (wxExecute(argv))
return true;
}
}
else if (desktop == wxT("KDE"))
{
// kfmclient directly opens the given URL
if (wxExecute(wxT("kfmclient openURL ") + params.GetPathOrURL()))
argv[2] = argv[1];
argv[0] = "kfmclient";
argv[1] = "openURL";
argv[3] = NULL;
if (wxExecute(argv))
return true;
}