util.jsonpointer: Fix off-by-one in array resolution 0.12
authorKim Alvefur <zash@zash.se>
Sun, 08 May 2022 18:04:50 +0200
branch0.12
changeset 12500 87c3d45208ef
parent 12499 5bf9056dca2c
child 12501 83f269db6850
child 12503 03e307952816
util.jsonpointer: Fix off-by-one in array resolution Fixes #1753 Not known to be used anywhere
teal-src/util/jsonpointer.tl
util/jsonpointer.lua
--- a/teal-src/util/jsonpointer.tl	Sun May 08 18:03:44 2022 +0200
+++ b/teal-src/util/jsonpointer.tl	Sun May 08 18:04:50 2022 +0200
@@ -24,7 +24,7 @@
 		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
--- a/util/jsonpointer.lua	Sun May 08 18:03:44 2022 +0200
+++ b/util/jsonpointer.lua	Sun May 08 18:04:50 2022 +0200
@@ -20,7 +20,7 @@
 			if token == "-" then
 				i = #ref + 1
 			end
-			new_ref = ref[i]
+			new_ref = ref[i + 1]
 		else
 			return nil, "invalid-table"
 		end