zhoujiexiong commented on code in PR #11367:
URL: https://github.com/apache/apisix/pull/11367#discussion_r1663643221


##########
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:
   For the `supported` cases, if there are exceptions,
   `pb_encode` without `pcall` would get response_body like following quoted 
text, which can also fail the test case.
   
   In this test case, we mainly focus on the `unsupported` cases and the 
corresponding error `bad argument #2 to '?' (number/'#number' expected for 
field 'values', got string)`
   
   ```
   #          got: '<html>
   # <head><title>500 Internal Server Error</title></head>
   # <body>
   # <center><h1>500 Internal Server Error</h1></center>
   # <hr><center>openresty/1.25.3.1</center>
   # <p><em>Powered by <a 
href="https://apisix.apache.org/";>APISIX</a>.</em></p></body>
   # </html>
   # '
   ```



-- 
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: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to