Skip to content

Commit

Permalink
Fix "lang.Error ([] operator not supported for strings)"
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Sep 29, 2024
1 parent e17230b commit 9962467
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Web change log

## ?.?.? / ????-??-??

* Fixed error *[] operator not supported for strings* when handling array
parameters
(@thekid)
* Fixed multipart/formdata field names and values decoding, these are not
urlencoded. Ignore the specification which states `"`, `\r` and `\n`
need to be escaped for consistency with PHP, see php/php-src#8206
Expand Down
2 changes: 2 additions & 0 deletions src/main/php/web/io/Param.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public function merge(&$ptr) {
$p= strcspn($this->array, ']', $o);
$token= substr($this->array, $o + 1, $p - 1);

is_array($ptr) || $ptr= [];

if ('' === $token) {
$ptr= &$ptr[];
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/test/php/web/unittest/ParamsTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ private function merge() {
['access[0][]', 'calendar'],
['access[1][]', 'wiki'],
]];
yield [[
['key', 'value'],
['key[]', 'test'],
]];
}

#[Test, Values(from: 'params')]
Expand Down

0 comments on commit 9962467

Please sign in to comment.