Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lorispath from PSR7 request #9055

Merged
merged 2 commits into from
Feb 27, 2024

Conversation

MaximeMulder
Copy link
Contributor

@MaximeMulder MaximeMulder commented Feb 14, 2024

Brief summary of changes

Removes lorispath from the PSR7 request's query parameters and uri query string (both must be updated separately).
Manipulating arrays in PHP is so verbose 馃槾.

Testing instructions

var dump $serverrequest

Links to related issues

Comment on lines +50 to +57
$query = implode(
"&",
array_map(
fn ($key, $value) => $key . "=" . $value,
array_keys($params),
$params
)
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not use http_build_query because the parameters should already be URL-encoded.

Copy link
Collaborator

@driusan driusan Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? Shouldn't it have been handled internally by the library after $serverrequest = $serverrequest->withQueryParams($params);?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? Shouldn't it have been handled internally by the library after $serverrequest = $serverrequest->withQueryParams($params);?

Yes it is, the request stores both the query parameters as an array and as a string in the URI. Changing one does not affect the other.

htdocs/index.php Outdated
// Remove the lorispath from the URI query parameters.
// Both the request query parameters and the URI query string must be updated.
$params = $serverrequest->getQueryParams();
$params = array_diff_key($params, ["lorispath" => null]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$params = array_diff_key($params, ["lorispath" => null]);
unset($params['lorispath']);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL PHP arrays are copy-on-write.
Applied.

@driusan driusan merged commit a55cb25 into aces:main Feb 27, 2024
28 checks passed
@ridz1208 ridz1208 added this to the 26.0.0 milestone Apr 9, 2024
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.

lorispath leaks into PSR7 request on Apache server
3 participants