Added handling for bad paths in env.json and index's JS

This commit is contained in:
rxi
2014-04-12 16:06:32 +01:00
parent 0dbc491f07
commit 23ee7daad6

View File

@@ -223,6 +223,12 @@ end
}
updateDivContent("envheader", html);
/* Handle invalid table path */
if (!json.valid) {
updateDivContent("envvars", "Bad path");
return;
}
/* Variables */
var html = "<table>";
for (var i = 0; json.vars[i]; i++) {
@@ -268,10 +274,16 @@ lovebird.pages["env.json"] = [[
if p ~= "" then
for x in p:gmatch("[^%.]+") do
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
?>
{
"valid": true,
"path": "<?lua echo(p) ?>",
"vars": [
<?lua