-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[BUG]: getJsonRawBody can return false for valid json #15608
Comments
You are using old and unsupported version of Phalcon. Please migrate your app to the latest. |
I think this one should be revisited, since we are experiencing a similar bug with phalcon 5.1.2 & php 8.1.13 on alpine 3.16: We have some code in a base controller similar to this: if ($this->request->getJsonRawBody()){
$request = $this->request->getJsonRawBody();
} else if ($this->request->isPost()) {
$request = (object) $this->request->getPost();
} else {
$request = (object) $this->request->getPut();
} This allows us to process the request using the same code regardless of the request type (JSON or formdata or whatever) Note that the first check involves calling Now, in a particular controller, we try to validate a JWT token (passed using a form, and NOT json) using code similar to this: $signer = new Hmac('sha256');
$parser = new Parser();
$tokenObject = $parser->parse($jwt);
//... Since the You would think that the call to |
@madrian-es Do you happen to have an example or a failing test for this so that I can test it? |
The reason it reaches that code path is because something is going on when decoding the headers. If you notice the To understand this better. What we need is anytime a Correct? |
@niden I was able to create a small repo that you can use to reproduce this fully. I tried to remove all the superfluous code that is not relevant to this bug, but there may be some unnecessary |
I will test it today. Note you do not need PSR with Phalcon 5.x. Just FYI |
I must have missed that when upgrading to 5, thanks for the heads up. |
Resolved in #16381 Thanks guys. |
Version | 3.4.3
Build Date | Apr 1 2019 13:32:28
Powered by Zephir | Version 0.10.14-975ad02db4
In php json_last_error reset error after every json_decode call.
If I use getJsonRawBody (internal call json_last_error can return error from prev call json_decode).
For example: POST with body {}
The text was updated successfully, but these errors were encountered: