Skip to content

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

Merged
starwing merged 1 commit into
starwing:masterfrom
zhoujiexiong:fix-lpb_tointegerx
Jun 19, 2024
Merged

fix(lpb_tointegerx): filter out illegal formats, such as, #a, #-aaa...#269
starwing merged 1 commit into
starwing:masterfrom
zhoujiexiong:fix-lpb_tointegerx

Conversation

@zhoujiexiong

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@coveralls

Copy link
Copy Markdown

Coverage Status

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

@zhoujiexiong

Copy link
Copy Markdown
Contributor Author

Hi @starwing ,

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

@starwing

Copy link
Copy Markdown
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