Skip to content

Add type validation before explode value - #246

Open
2646298 wants to merge 1 commit into
thephpleague:masterfrom
2646298:fix-convertion-to-serialization-style
Open

Add type validation before explode value#246
2646298 wants to merge 1 commit into
thephpleague:masterfrom
2646298:fix-convertion-to-serialization-style

Conversation

@2646298

@2646298 2646298 commented May 6, 2025

Copy link
Copy Markdown

Issue example

In openapi.yml documentation:

parameters:
  name: parameterName
  in: query
  explode: false
  schema:
    type: array
    items:
      type: string

In this case, the parameter is expected to be in the following format:

https://example.com/api/endpoint?parameterName=value1,value2,value3

However, if an invalid request is made like this:

https://example.com/api/endpoint?parameterName[]=value1&parameterName[]=value2

then $value = explode(self::STYLE_DELIMITER_MAP[$this->style], $value); will try to explode array and in PHP 8 throws fatal error: Fatal error: Uncaught TypeError: explode(): Argument #2 ($string) must be of type string, array given

Fix

Check that $value is a string before explode().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant