-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: Unable to use JWT Parser when getJsonRawBody is called #16373
Labels
Comments
The problem really exists public function getJsonRawBody(bool associative = false) -> <\stdClass> | array | bool
{
var rawBody;
let rawBody = this->getRawBody();
if typeof rawBody != "string" {
return false;
}
return json_decode(rawBody, associative);
} We can do validation and then an error will be shown for empty request and all projects will fail :) public function getJsonRawBody(bool associative = false) -> <\stdClass> | array | bool
{
var rawBody;
let rawBody = this->getRawBody();
if typeof rawBody != "string" {
return false;
}
var decoded;
let decoded = json_decode(rawBody, associative);
if unlikely JSON_ERROR_NONE !== json_last_error() {
throw new \InvalidArgumentException(
"json_decode error: " . json_last_error_msg()
);
}
return decoded;
} or this problem can be solved if we just will return public function getJsonRawBody(bool associative = false) -> <\stdClass> | array | bool
{
var rawBody;
let rawBody = this->getRawBody();
if typeof rawBody != "string" {
return false;
}
if rawBody == ""
{
return new \stdClass(); //or let rawBody == "{}"; as variant to work associative array
}
return json_decode(rawBody, associative);
} Guys what do you think? what's better? |
niden
added
status: medium
Medium
5.0
The issues we want to solve in the 5.0 release
and removed
status: unverified
Unverified
labels
Jul 25, 2023
sinbadxiii
added a commit
to sinbadxiii/cphalcon
that referenced
this issue
Jul 26, 2023
sinbadxiii
added a commit
to sinbadxiii/cphalcon
that referenced
this issue
Jul 26, 2023
Merged
5 tasks
Resolved in #16380 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Describe the bug
If getJsonRawBody is called, JWT parser throws an error instead of the parsed JWT
To Reproduce
If
$payload = $request->getJsonRawBody(true);
exists I get json_decode error: Syntax error instead of the parsed JWTDetails
The text was updated successfully, but these errors were encountered: