Software /
code /
prosody
Comparison
util/paseto.lua @ 12716:0b68b021ce46
util.paseto: Do strict type check in pae() function
Fixes a test failure on Lua 5.4 where ipairs("") does not produce an
error.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 11 Jul 2022 18:48:57 +0200 |
parent | 12713:52eead170bb8 |
child | 12838:2e71b76ac299 |
comparison
equal
deleted
inserted
replaced
12715:5dd00f806e32 | 12716:0b68b021ce46 |
---|---|
21 local function le64(n) | 21 local function le64(n) |
22 return s_pack("<I8", bit.band(n, 0x7F)); | 22 return s_pack("<I8", bit.band(n, 0x7F)); |
23 end | 23 end |
24 | 24 |
25 local function pae(parts) | 25 local function pae(parts) |
26 if type(parts) ~= "table" then | |
27 error("bad argument #1 to 'pae' (table expected, got "..type(parts)..")"); | |
28 end | |
26 local o = { le64(#parts) }; | 29 local o = { le64(#parts) }; |
27 for _, part in ipairs(parts) do | 30 for _, part in ipairs(parts) do |
28 table.insert(o, le64(#part)..part); | 31 table.insert(o, le64(#part)..part); |
29 end | 32 end |
30 return table.concat(o); | 33 return table.concat(o); |