php/php-src — pull request #413 by LawnGnome (2013-08-19 22:42:27+00:00)
Title: Make exception messages and error output binary safe

This will probably need an RFC, but until I have time to write one, this PR will have to do to track this.

Previously, exception messages were documented as not being binary safe. The reality was actually more complicated than this: `Exception::$message` itself was binary safe if accessed through `Exception::getMessage()`, but wasn't binary safe when the full exception string was constructed by `Exception::__toString()`.

I dislike arbitrary restrictions and inconsistent behaviour, hence this PR.

9b1069f removes the exception restriction. By itself, that still isn't all that useful, since error output also isn't binary safe. The follow up commits remove that restriction (of course, if your actual stdout/stderr aren't binary safe, you have lost regardless).

Things that would still have to be dealt with before this became mergeable:

* Windows testing. The actual code change in main/main.c is pretty mechanical, but I don't know how it'll behave in Windows' weird console.
* This is going to be slower, due to the additional printf calls and the additional mallocs and frees in `Exception::__toString()`. Is that really a problem in practice? Error and exception code aren't speed demons at the best of times.
* The fact that error output now comes in multiple chunks may cause problems (although honestly, I'd hope not in practice).