mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-17 16:58:14 +00:00
core: OpenURL() fix xdg-open call
Calling just `xdg-open` is not right. One needs to pack the URL in `'`. If we don't do this then some special characters (like ampersand) will be executed. Maybe this is true for Windows and Apple case too, but I don't own any such system. So please merge this, and if it's true for more cases let's use `sprintf()` in the other cases too.
This commit is contained in:
@@ -1823,14 +1823,17 @@ int StorageLoadValue(int position)
|
|||||||
void OpenURL(const char *url)
|
void OpenURL(const char *url)
|
||||||
{
|
{
|
||||||
char *cmd = calloc(10 + strlen(url), sizeof(char));
|
char *cmd = calloc(10 + strlen(url), sizeof(char));
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
strcpy(cmd, "explorer ");
|
strcpy(cmd, "explorer ");
|
||||||
|
strcat(cmd, url);
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
strcpy(cmd, "xdg-open "); // Alternatives: firefox, x-www-browser
|
sprintf(cmd, "xdg-open '%s'", url); // Alternatives: firefox, x-www-browser
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
strcpy(cmd, "open ");
|
strcpy(cmd, "open ");
|
||||||
#endif
|
|
||||||
strcat(cmd, url);
|
strcat(cmd, url);
|
||||||
|
#endif
|
||||||
|
|
||||||
system(cmd);
|
system(cmd);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user