Skip to content

Commit 9962467

Browse files
committed
Fix "lang.Error ([] operator not supported for strings)"
1 parent e17230b commit 9962467

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Web change log
33

44
## ?.?.? / ????-??-??
55

6+
* Fixed error *[] operator not supported for strings* when handling array
7+
parameters
8+
(@thekid)
69
* Fixed multipart/formdata field names and values decoding, these are not
710
urlencoded. Ignore the specification which states `"`, `\r` and `\n`
811
need to be escaped for consistency with PHP, see php/php-src#8206

src/main/php/web/io/Param.class.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public function merge(&$ptr) {
7575
$p= strcspn($this->array, ']', $o);
7676
$token= substr($this->array, $o + 1, $p - 1);
7777

78+
is_array($ptr) || $ptr= [];
79+
7880
if ('' === $token) {
7981
$ptr= &$ptr[];
8082
} else {

src/test/php/web/unittest/ParamsTest.class.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ private function merge() {
7272
['access[0][]', 'calendar'],
7373
['access[1][]', 'wiki'],
7474
]];
75+
yield [[
76+
['key', 'value'],
77+
['key[]', 'test'],
78+
]];
7579
}
7680

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

0 commit comments

Comments
 (0)