use thisfunc() instead of caller(0)[1]
This commit is contained in:
parent
54e6ec55b4
commit
7bbbfa6a8e
2 changed files with 6 additions and 6 deletions
10
Nasal/io.nas
10
Nasal/io.nas
|
@ -210,7 +210,7 @@ var writexml = func(path, node, indent = "\t", prefix = "___") {
|
||||||
# Redefine io.open() such that files can only be opened under authorized directories.
|
# Redefine io.open() such that files can only be opened under authorized directories.
|
||||||
#
|
#
|
||||||
_setlistener("/sim/signals/nasal-dir-initialized", func {
|
_setlistener("/sim/signals/nasal-dir-initialized", func {
|
||||||
var self = caller(0)[1];
|
var self = thisfunc();
|
||||||
var root = string.fixpath(getprop("/sim/fg-root"));
|
var root = string.fixpath(getprop("/sim/fg-root"));
|
||||||
var home = string.fixpath(getprop("/sim/fg-home"));
|
var home = string.fixpath(getprop("/sim/fg-home"));
|
||||||
var config = "Nasal/IOrules";
|
var config = "Nasal/IOrules";
|
||||||
|
@ -276,8 +276,7 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
var _open = io.open;
|
var io_open = func(path, mode = "rb") {
|
||||||
io.open = func(path, mode = "rb") {
|
|
||||||
var rules = write_rules;
|
var rules = write_rules;
|
||||||
if(mode == "r" or mode == "rb" or mode == "br")
|
if(mode == "r" or mode == "rb" or mode == "br")
|
||||||
rules = read_rules;
|
rules = read_rules;
|
||||||
|
@ -287,11 +286,12 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
|
||||||
|
|
||||||
die("io.open(): opening file '" ~ path ~ "' denied (unauthorized access)\n ");
|
die("io.open(): opening file '" ~ path ~ "' denied (unauthorized access)\n ");
|
||||||
}
|
}
|
||||||
|
var _open = io.open;
|
||||||
|
io.open = io_open;
|
||||||
|
|
||||||
var _io_open = io.open;
|
|
||||||
var _closure = globals.closure;
|
var _closure = globals.closure;
|
||||||
globals.closure = func(fn, level = 0) {
|
globals.closure = func(fn, level = 0) {
|
||||||
if(fn != self and fn != caller(0)[1] and fn != _io_open)
|
if(fn != self and fn != thisfunc() and fn != io_open)
|
||||||
return _closure(fn, level);
|
return _closure(fn, level);
|
||||||
|
|
||||||
die("closure(): query denied (unauthorized access)\n ");
|
die("closure(): query denied (unauthorized access)\n ");
|
||||||
|
|
|
@ -140,7 +140,7 @@ match = func(str, patt) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (; s < size(str); s += 1)
|
for (; s < size(str); s += 1)
|
||||||
if (caller(0)[1](substr(str, s), substr(patt, p)))
|
if (thisfunc()(substr(str, s), substr(patt, p)))
|
||||||
return 1;
|
return 1;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue