Re: Allow empty property names
| From: | Yasuo Ohgaki | Date: | Fri, 25 Mar 2016 22:56:59 +0000 |
| Subject: | Re: Allow empty property names | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91956@lists.php.net to get a copy of this message | ||
Hi all,
On Sat, Mar 26, 2016 at 5:31 AM, Marco Pivetta <ocramius@gmail.com> wrote:
> var_dump((object) ['' => 'foo']);
> var_dump((object) ["\0*\0" => 'foo']);
> var_dump((object) ["\0Foo\0" => 'foo']);
Allowing null char would be too much. We reject null char in path
parameters, it should be rejected like path parameter. IMHO.
Postgresql decided not to allow null char as valid unicode string in
JSONB, for example.
http://www.postgresql.org/docs/9.4/static/datatype-json.html
The jsonb type also rejects \u0000 (because that cannot be
represented in PostgreSQL's text type)
Postgresql has it own reason why null char cannot be supported. PHP
may suppport it., but I'm 30/70 for supporting null char in property
name because I cannot think of any use cases other than attacking
applications. (BTW, null char in data should be supported as it is
now)
Array key supports binary strings. If there is vote for this change, I
would refrain from voting.
php > var_dump(["abc\0xyz"=>1234]);
php shell code:1:
array(1) {
'abc\0xyz' =>
int(1234)
}
var_dump($o->{'123Foo'}); works. ($o->123Foo is illegal)
Therefore, +1 for making $o->{''} to work and removing automatic '' ->
'_empty_' conversion.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net