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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning in Integration\CoolUri (method extractArraysFromParams) #92

Open
aimcom opened this issue Jan 10, 2019 · 2 comments · May be fixed by #93
Open

Warning in Integration\CoolUri (method extractArraysFromParams) #92

aimcom opened this issue Jan 10, 2019 · 2 comments · May be fixed by #93

Comments

@aimcom
Copy link

aimcom commented Jan 10, 2019

Line 613 of Classes/Integration/CoolUri.php is source of a warning if there is an array in the GET parameters.

E.g. if there is a param like "&my_extension_plugin[action]=show".

The problem can be solved by adding an additional check before encoding the value.

This is a possible solution (replacement for the line foreach ($params as $k => $v) $params[$k] = $k . '=' . rawurlencode($v);):

foreach ($params as $param => $value) {
	if (!is_array($value)) {
		$params[$param] = $param . '=' . rawurlencode($value);
	} else {
		foreach ($value as $subParam => $subValue) {
			$params[$param] = $param . '[' . $subParam . ']=' . rawurlencode($subValue);
		}
	}
}
@mad-develop
Copy link
Contributor

Confirmed. I'll make a pull request when i have tested these changes.
Related: #90

@mad-develop
Copy link
Contributor

mad-develop commented Jan 30, 2019

Still a warning when having multidim arrays (&my_extension_plugin[filter][name]=something)

This could be a fix. Using GeneralUtility::implodeArrayForUrl.

private static function extractArraysFromParams($params)
{
    // turn array back into query string
    // so it can be used with parse_str
    if (empty($params)) {
        return [];
    }

    $qs = \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('', $params);
    parse_str($qs, $output);
    return $output;
}

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 a pull request may close this issue.

2 participants