Skip to content

[4.x] Do not use input values as filter names in getArray() - #56

Open
Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-getarray-default-filter
Open

Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-getarray-default-filter

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

Called without arguments, Input::getArray() iterates over the input data and calls $this->get($key, null, $value), so the client-supplied value becomes the filter name for its own key. A request with name=int&flag=bool&list=array comes back as ['name' => 0, 'flag' => true, 'list' => ['array']], so anyone who types a filter name into a field gets corrupted data. The docblock promises filtering "using the default case in InputFilter::clean" instead.

The no-argument case now walks the data itself: strings (also inside nested arrays) are filtered with the string filter, which is what the default case of InputFilter::clean() does, and other values (integers, null, …) are returned unchanged.

Testing Instructions

New InputTest::testGetArrayWithoutSpecifiedVariablesDoesNotUseValuesAsFilters() uses the real InputFilter (the existing test mocks clean() to return its argument, so it could not catch this). It fails before the change ('name' => 0, 'html' => 'bold' missing etc.) and passes after it.

$input = new Joomla\Input\Input(['name' => 'int', 'flag' => 'bool']);
var_dump($input->getArray()); // before: ['name' => 0, 'flag' => true]; after: ['name' => 'int', 'flag' => 'bool']

Documentation Changes Required

docs/overview.md ("Reading several values at once"): the warning about values being used as filter names is replaced by the actual behaviour.

🤖 Generated with Claude Code

Called without arguments, getArray() iterated over the input data and
passed each value as the filter name for its own key, so a field whose
value happened to be a filter name ("int", "bool", "array", ...) came back
corrupted. Strings are now filtered with the 'string' filter, as the
docblock promised, and other values are returned unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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