Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tales of MajEyal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Otowa Kotori
Tales of MajEyal
Commits
3fbb964f
Commit
3fbb964f
authored
8 years ago
by
DarkGod
Browse files
Options
Downloads
Patches
Plain Diff
Removed os.execute altogether
parent
3c131d28
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
game/engines/default/engine/utils.lua
+2
-27
2 additions, 27 deletions
game/engines/default/engine/utils.lua
game/loader/pre-init.lua
+8
-0
8 additions, 0 deletions
game/loader/pre-init.lua
src/core_lua.c
+23
-0
23 additions, 0 deletions
src/core_lua.c
with
33 additions
and
27 deletions
game/engines/default/engine/utils.lua
+
2
−
27
View file @
3fbb964f
...
...
@@ -2315,7 +2315,6 @@ function util.uuid()
end
function
util
.
browserOpenUrl
(
url
,
forbid_methods
)
local
osexecute
=
os.execute
forbid_methods
=
forbid_methods
or
{}
if
forbid_methods
.
is_external
and
config
.
settings
.
open_links_external
then
forbid_methods
.
webview
=
true
...
...
@@ -2324,25 +2323,10 @@ function util.browserOpenUrl(url, forbid_methods)
if
core
.
webview
and
not
forbid_methods
.
webview
then
local
d
=
require
(
"engine.ui.Dialog"
):
webPopup
(
url
)
if
d
then
return
"webview"
,
d
end
end
if
core
.
steam
and
not
forbid_methods
.
steam
and
core
.
steam
.
openOverlayUrl
(
url
)
then
return
"steam"
,
true
end
if
forbid_methods
.
native
then
return
false
end
if
core
.
game
.
openBrowser
(
url
)
then
return
"native"
,
true
end
local
tries
=
{
"rundll32 url.dll,FileProtocolHandler %s"
,
-- Windows
"open %s"
,
-- OSX
"xdg-open %s"
,
-- Linux - portable way
"gnome-open %s"
,
-- Linux - Gnome
"kde-open %s"
,
-- Linux - Kde
"firefox %s"
,
-- Linux - try to find something
"mozilla-firefox %s"
,
-- Linux - try to find something
"google-chrome-stable %s"
,
-- Linux - try to find something
"google-chrome %s"
,
-- Linux - try to find something
}
while
#
tries
>
0
do
local
urlbase
=
table.remove
(
tries
,
1
)
urlbase
=
urlbase
:
format
(
url
)
print
(
"Trying to run URL with command: "
,
urlbase
)
if
osexecute
(
urlbase
)
==
0
then
return
"native"
,
true
end
end
return
false
end
...
...
@@ -2390,12 +2374,3 @@ end
function
util
.
steamCanCloud
()
if
core
.
steam
and
core
.
steam
.
isCloudEnabled
(
true
)
and
core
.
steam
.
isCloudEnabled
(
false
)
and
not
savefile_pipe
.
disable_cloud_saves
then
return
true
end
end
--------------------------------------------------------------
-- Remove invalidate some dangerous functions
--------------------------------------------------------------
os.execute
=
nil
os.getenv
=
nil
os.remove
=
nil
os.rename
=
nil
This diff is collapsed.
Click to expand it.
game/loader/pre-init.lua
+
8
−
0
View file @
3fbb964f
...
...
@@ -185,3 +185,11 @@ function string.unserialize(str)
local
ok
,
err
=
pcall
(
f
)
if
ok
then
return
setmetatable
(
t
,
nil
)
else
print
(
"[UNSERIALIZE] error"
,
err
)
return
nil
end
end
--------------------------------------------------------------
-- Remove invalidate some dangerous functions
--------------------------------------------------------------
os.execute
=
nil
os.getenv
=
nil
os.remove
=
nil
os.rename
=
nil
This diff is collapsed.
Click to expand it.
src/core_lua.c
+
23
−
0
View file @
3fbb964f
...
...
@@ -597,6 +597,28 @@ static int lua_force_next_tick(lua_State *L)
return
0
;
}
static
int
lua_open_browser
(
lua_State
*
L
)
{
#if defined(SELFEXE_LINUX) || defined(SELFEXE_BSD)
const
char
*
command
=
"xdg-open
\"
%s
\"
"
;
#elif defined(SELFEXE_WINDOWS)
const
char
*
command
=
"rundll32 url.dll,FileProtocolHandler
\"
%s
\"
"
;
#elif defined(SELFEXE_MACOSX)
const
char
*
command
=
"open
\"
%s
\"
"
;
#else
{
return
0
;
}
#endif
char
buf
[
2048
];
size_t
len
;
char
*
path
=
strdup
(
luaL_checklstring
(
L
,
1
,
&
len
));
size_t
i
;
for
(
i
=
0
;
i
<
len
;
i
++
)
if
(
path
[
i
]
==
'"'
)
path
[
i
]
=
'_'
;
// Just dont put " in there
snprintf
(
buf
,
2047
,
command
,
path
);
lua_pushboolean
(
L
,
system
(
buf
)
==
0
);
return
1
;
}
static
const
struct
luaL_Reg
gamelib
[]
=
{
{
"setRebootMessage"
,
lua_set_reboot_message
},
...
...
@@ -612,6 +634,7 @@ static const struct luaL_Reg gamelib[] =
{
"requestNextTick"
,
lua_force_next_tick
},
{
"checkError"
,
lua_check_error
},
{
"resetLocale"
,
lua_reset_locale
},
{
"openBrowser"
,
lua_open_browser
},
{
NULL
,
NULL
},
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment