comparison teal-src/util/jsonpointer.tl @ 12496:87c3d45208ef 0.12

util.jsonpointer: Fix off-by-one in array resolution Fixes #1753 Not known to be used anywhere
author Kim Alvefur <zash@zash.se>
date Sun, 08 May 2022 18:04:50 +0200
parents b4c0efff8dd3
children
comparison
equal deleted inserted replaced
12495:5bf9056dca2c 12496:87c3d45208ef
22 if idx is string then 22 if idx is string then
23 new_ref = ref[token] 23 new_ref = ref[token]
24 elseif idx is integer then 24 elseif idx is integer then
25 local i = tonumber(token) 25 local i = tonumber(token)
26 if token == "-" then i = #ref + 1 end 26 if token == "-" then i = #ref + 1 end
27 new_ref = ref[i] 27 new_ref = ref[i+1]
28 else 28 else
29 return nil, "invalid-table" 29 return nil, "invalid-table"
30 end 30 end
31 31
32 if pos as integer == ptr_len then 32 if pos as integer == ptr_len then