Hi internals,

A regular annoyance with our test suite is that var_dump() prints null
bytes literally, those null bytes get into our test expectations, the test
is interpreted as a binary file by git, and diffs will not be shown on
GitHub.

Of course, the null bytes are also confusing to the reader, as many editors
will not display them, and the only indication that they are there is the
string length.

https://github.com/php/php-src/pull/7059 does a surgical change to replace
null bytes with \0.

A potential problem is that this no longer allows an easy distinction
between "\0" and "\\0", as both will be printed as "\0". We could resolve
this by additionally escaping \ (and presumably "). See
https://gist.github.com/nikic/d3d74d88178ea6946305e0b2d38a84f9 for an rough
idea on the impact on Zend and ext/standard tests.

So, I'd be interested in knowing
a) whether var_dump() should be performing any escaping at all, and if yes
b) how much we should be escaping. Just \0, both \0 and \ to avoid
ambiguity, or a larger set of control characters?

Regards,
Nikita

Reply via email to