aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-05-09 22:40:45 +0200
committerKim Alvefur <zash@zash.se>2022-05-09 22:40:45 +0200
commit9135764484d017855896e143380747bf66336f73 (patch)
treebbf50bad48d3cec71575e939b2da815b6a2ca0ab /util
parent117c340edbb7512b911038e40201e64135b966f8 (diff)
parent6a9efa5a52289b58401faf6e3deb7a2272dd323a (diff)
downloadprosody-9135764484d017855896e143380747bf66336f73.tar.gz
prosody-9135764484d017855896e143380747bf66336f73.zip
Merge 0.12->trunk
Diffstat (limited to 'util')
-rw-r--r--util/jsonpointer.lua6
-rw-r--r--util/jsonschema.lua5
2 files changed, 9 insertions, 2 deletions
diff --git a/util/jsonpointer.lua b/util/jsonpointer.lua
index dd5ac9d6..9b871ae7 100644
--- a/util/jsonpointer.lua
+++ b/util/jsonpointer.lua
@@ -1,3 +1,7 @@
+local m_type = math.type or function (n)
+ return n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float";
+end;
+
local function unescape_token(escaped_token)
local unescaped = escaped_token:gsub("~1", "/"):gsub("~0", "~")
return unescaped
@@ -15,7 +19,7 @@ local function resolve_json_pointer(ref, path)
if type(idx) == "string" then
new_ref = ref[token]
- elseif math.type(idx) == "integer" then
+ elseif m_type(idx) == "integer" then
local i = tonumber(token)
if token == "-" then
i = #ref + 1
diff --git a/util/jsonschema.lua b/util/jsonschema.lua
index 65974a84..8286fa19 100644
--- a/util/jsonschema.lua
+++ b/util/jsonschema.lua
@@ -1,3 +1,6 @@
+local m_type = math.type or function (n)
+ return n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float";
+end;
local json = require("util.json")
local null = json.null;
@@ -17,7 +20,7 @@ local function simple_validate(schema, data)
elseif schema == "array" and type(data) == "table" then
return type(data) == "table" and (next(data) == nil or type((next(data, nil))) == "number")
elseif schema == "integer" then
- return math.type(data) == schema
+ return m_type(data) == schema
elseif schema == "null" then
return data == null
else