Skip to content

Commit 5108baf

Browse files
committed
Refactor query string parsing for RelayState redirect
This commit is replacing `parse_url` by `wp_parse_url` function, which is a WordPress wrapper for PHP inconsistencies. While working on related code, this PR is cleaning up the code. * There is no need to parse and obtain whole url. Passing PHP_URL_QUERY to `wp_parse_url` function gets us just the bit we need. * There is no need to define the `$result` param prior calling `parse_str` function. * variable `$target` is not being used. Thus has been removed.
1 parent 1e07ba4 commit 5108baf

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

onelogin-saml-sso/php/functions.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,8 @@ function saml_acs() {
291291
wp_redirect(home_url());
292292
} else {
293293
if (strpos($_REQUEST['RelayState'], 'redirect_to') !== false) {
294-
$urlinfo = parse_url($_REQUEST['RelayState']);
295-
$parameters = array();
296-
parse_str($urlinfo['query'], $parameters);
297-
$target = urldecode($parameters['redirect_to']);
294+
$query = wp_parse_url($_REQUEST['RelayState'], PHP_URL_QUERY);
295+
parse_str( $query, $parameters );
298296
wp_redirect(urldecode($parameters['redirect_to']));
299297
} else {
300298
wp_redirect($_REQUEST['RelayState']);

0 commit comments

Comments
 (0)