Skip to content

Commit 72c1948

Browse files
committed
improve opening profiling url
1 parent fb08877 commit 72c1948

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

sources/include/cage-core/process.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ namespace cage
3636
CAGE_CORE_API void installSigTermHandler(Delegate<void()> handler);
3737
CAGE_CORE_API void installSigIntHandler(Delegate<void()> handler);
3838

39+
// the url may need some preparation (replace spaces with %20)
40+
// the function may silently fail
3941
CAGE_CORE_API void openUrl(const String &url);
4042
}
4143

sources/libcore/concurrent/openUrl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ namespace cage
3838

3939
void openUrl(const String &url)
4040
{
41+
CAGE_LOG(SeverityEnum::Info, "openUrl", Stringizer() + "opening browser with url: " + url);
4142
#ifdef CAGE_SYSTEM_WINDOWS
4243
if (!windowsTryFile(url))
4344
ShellExecute(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
4445
#else
45-
std::system((Stringizer() + "xdg-open " + url).value.c_str());
46+
const String s = replace(url, "\"", "\\\"");
47+
std::system((Stringizer() + "xdg-open \"" + s + "\"").value.c_str());
4648
#endif
4749
}
4850
}

sources/libcore/profiling.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <cage-core/concurrent.h>
99
#include <cage-core/concurrentQueue.h>
1010
#include <cage-core/config.h>
11+
#include <cage-core/string.h>
1112
#include <cage-core/files.h>
1213
#include <cage-core/math.h>
1314
#include <cage-core/networkWebsocket.h>
@@ -202,7 +203,7 @@ namespace cage
202203
try
203204
{
204205
writeFile("profiling.htm")->write(profiling_htm().cast<const char>());
205-
const String baseUrl = pathWorkingDir() + "/profiling.htm";
206+
const String baseUrl = replace(pathWorkingDir(), " ", "%20") + "/profiling.htm";
206207
const String url = Stringizer() + "file://" + baseUrl + "?port=" + server->port();
207208
openUrl(url);
208209
}

0 commit comments

Comments
 (0)