mirror of
https://github.com/TangentFoxy/lovebird.git
synced 2025-07-28 11:02:19 +00:00
Added handling for bad paths in env.json and index's JS
This commit is contained in:
12
lovebird.lua
12
lovebird.lua
@@ -223,6 +223,12 @@ end
|
|||||||
}
|
}
|
||||||
updateDivContent("envheader", html);
|
updateDivContent("envheader", html);
|
||||||
|
|
||||||
|
/* Handle invalid table path */
|
||||||
|
if (!json.valid) {
|
||||||
|
updateDivContent("envvars", "Bad path");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Variables */
|
/* Variables */
|
||||||
var html = "<table>";
|
var html = "<table>";
|
||||||
for (var i = 0; json.vars[i]; i++) {
|
for (var i = 0; json.vars[i]; i++) {
|
||||||
@@ -268,10 +274,16 @@ lovebird.pages["env.json"] = [[
|
|||||||
if p ~= "" then
|
if p ~= "" then
|
||||||
for x in p:gmatch("[^%.]+") do
|
for x in p:gmatch("[^%.]+") do
|
||||||
t = t[x]
|
t = t[x]
|
||||||
|
-- Return early if path does not exist
|
||||||
|
if type(t) ~= "table" then
|
||||||
|
echo('{ "valid": false, "path": ' .. string.format("%q", p) .. ' }')
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
?>
|
?>
|
||||||
{
|
{
|
||||||
|
"valid": true,
|
||||||
"path": "<?lua echo(p) ?>",
|
"path": "<?lua echo(p) ?>",
|
||||||
"vars": [
|
"vars": [
|
||||||
<?lua
|
<?lua
|
||||||
|
Reference in New Issue
Block a user