shreemaan-abhishek commented on code in PR #11367:
URL: https://github.com/apache/apisix/pull/11367#discussion_r1663486023
##########
t/plugin/grpc-transcode3.t:
##########
@@ -525,3 +525,44 @@ location /t {
end
}
}
+
+
+
+=== TEST 13: bugfix - filter out illegal INT(string) formats
+--- config
+location /t {
+ content_by_lua_block {
+ local pb = require "pb"
+ local pb_encode = pb.encode
+ local protoc = require "protoc"
+ local pcall = pcall
+
+ assert(protoc:load [[
+ syntax = "proto3";
+ message IntStringPatterns {
+ repeated int64 values = 1;
+ }]])
+
+ local supported = {
+ values = {
+ 1, 2, -3, "#123", "0xabF", "#-0x123abcdef", "-#0x123abcdef",
"#0x123abc", "123",
+ },
+ }
+
+ local unsupported = {
+ values = {
+ "#a", "+aaa", "#aaaaa", "#-aa",
+ },
+ }
+
+ --pb.option "int64_as_string"
+ --pb.option "int64_as_hexstring"
+ pb_encode("IntStringPatterns", supported)
Review Comment:
why ignore the result of pb_encode?
##########
t/plugin/grpc-transcode3.t:
##########
@@ -525,3 +525,44 @@ location /t {
end
}
}
+
+
+
+=== TEST 13: bugfix - filter out illegal INT(string) formats
+--- config
+location /t {
+ content_by_lua_block {
+ local pb = require "pb"
+ local pb_encode = pb.encode
+ local protoc = require "protoc"
+ local pcall = pcall
+
+ assert(protoc:load [[
+ syntax = "proto3";
+ message IntStringPatterns {
+ repeated int64 values = 1;
+ }]])
+
+ local supported = {
+ values = {
+ 1, 2, -3, "#123", "0xabF", "#-0x123abcdef", "-#0x123abcdef",
"#0x123abc", "123",
+ },
+ }
+
+ local unsupported = {
+ values = {
+ "#a", "+aaa", "#aaaaa", "#-aa",
+ },
+ }
+
+ --pb.option "int64_as_string"
+ --pb.option "int64_as_hexstring"
+ pb_encode("IntStringPatterns", supported)
+ local status, err = pcall(pb_encode, "IntStringPatterns", unsupported)
Review Comment:
I think it would be better to avoid using `repeated` and check all
supported/unsupported types in a loop.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]