Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lpb_tointegerx): filter out illegal formats, such as, #a, #-aaa... #269

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

zhoujiexiong
Copy link
Contributor

local pb = require "pb"
local protoc = require "protoc"

assert(protoc:load [[
syntax = "proto3";
message Money {
  string currency = 1;
  repeated int64 values = 2;
}]])

local data = {
    currency = "MYR",
    values = {
	-- cases supported
	1, 2, -3, "#123", "0xabF", "#-0x123abcdef", "-#0x123abcdef", "#0x123abc", "123",
	-- cases filtered out
	--- "a", "+aaa", "#aaaaa",
    },
}

--pb.option "int64_as_string"
--pb.option "int64_as_hexstring"

local bytes = assert(pb.encode("Money", data))
print(pb.tohex(bytes))
print(ngx.encode_base64(bytes))

local data2 = assert(pb.decode("Money", bytes))
print(require "serpent".block(data2))

@zhoujiexiong
Copy link
Contributor Author

ping @starwing

@zhoujiexiong zhoujiexiong changed the title fix(lpb_tointegerx): filter out the malformat, such as, #a, #-aaa... fix(lpb_tointegerx): filter out illegal formats, such as, #a, #-aaa... Jun 19, 2024
@starwing
Copy link
Owner

Good catch, thanks for contribution!

@starwing starwing closed this Jun 19, 2024
@starwing starwing reopened this Jun 19, 2024
@starwing starwing merged commit 3f9ffd4 into starwing:master Jun 19, 2024
6 checks passed
@coveralls
Copy link

Coverage Status

coverage: 99.611%. remained the same
when pulling ad75e24 on zhoujiexiong:fix-lpb_tointegerx
into 5e99872 on starwing:master.

@zhoujiexiong
Copy link
Contributor Author

Hi @starwing ,

Would you please help release new version to luarocks? Thx.

@starwing
Copy link
Owner

@zhoujiexiong done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants