Skip to content

Commit

Permalink
Update sfs.lua
Browse files Browse the repository at this point in the history
Add type checking for input when decoding to make sure that the supplied argument is a string
  • Loading branch information
Srlion authored Aug 28, 2024
1 parent 1f8c69a commit 009083e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sfs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,10 @@ do
end

function Decoder.decode(str)
if type(str) ~= "string" then
return nil, "str is not a string", str
end

context[1] = 1
context[2] = str
context[3] = #str
Expand All @@ -528,6 +532,10 @@ do
end

function Decoder.decode_with_max_size(str, max_size)
if type(str) ~= "string" then
return nil, "str is not a string", str
end

if type(max_size) ~= "number" then
return nil, "max_size is not a number", max_size
end
Expand Down Expand Up @@ -1157,5 +1165,5 @@ return {
end,

chars = chars,
VERSION = "2.0.5"
VERSION = "2.0.6"
}

0 comments on commit 009083e

Please sign in to comment.