From d05af9f2b54d292b49b694d8317152f4339f7076 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 8 May 2022 18:04:50 +0200 Subject: util.jsonpointer: Fix off-by-one in array resolution Fixes #1753 Not known to be used anywhere --- teal-src/util/jsonpointer.tl | 2 +- util/jsonpointer.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/teal-src/util/jsonpointer.tl b/teal-src/util/jsonpointer.tl index 7b9db760..c21e1fbf 100644 --- a/teal-src/util/jsonpointer.tl +++ b/teal-src/util/jsonpointer.tl @@ -24,7 +24,7 @@ local function resolve_json_pointer(ref : table, path : string) : any, ptr_error elseif idx is integer then local i = tonumber(token) if token == "-" then i = #ref + 1 end - new_ref = ref[i] + new_ref = ref[i+1] else return nil, "invalid-table" end diff --git a/util/jsonpointer.lua b/util/jsonpointer.lua index 7c657266..dd5ac9d6 100644 --- a/util/jsonpointer.lua +++ b/util/jsonpointer.lua @@ -20,7 +20,7 @@ local function resolve_json_pointer(ref, path) if token == "-" then i = #ref + 1 end - new_ref = ref[i] + new_ref = ref[i + 1] else return nil, "invalid-table" end -- cgit v1.2.3