bradib0y commented on issue #11687:
URL: https://github.com/apache/apisix/issues/11687#issuecomment-2442808114
I fixed the bug and wrote a test case, but I was not able to run it
fix (request-validation.lua)
```
local body_is_json = true
local FORM_URLENCODED_MEDIA_TYPE="application/x-www-form-urlencoded"
if string.sub(headers["content-type"], 1,
string.len(FORM_URLENCODED_MEDIA_TYPE)) ==
FORM_URLENCODED_MEDIA_TYPE then
-- use 0 to avoid truncated result and keep the behavior as the
-- same as other platforms
req_body, err = ngx.decode_args(body, 0)
body_is_json = false
else -- JSON as default
req_body, err = core.json.decode(body)
end
```
test case (request-validation.t)
```
=== TEST 53: test urlencoded post data with charset parameter
--- more_headers
Content-Type: application/x-www-form-urlencoded; charset=utf-8
--- request eval
"POST /echo
" . "a=b&" x 101 . "required_payload=101-hello"
--- response_body eval
qr/101-hello/
```
--
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]