phpv8 / v8js

V8 Javascript Engine for PHP — This PHP extension embeds the Google V8 Javascript Engine
http://pecl.php.net/package/v8js
MIT License
1.83k stars 200 forks source link

String with NULL-byte passback from JS to PHP fails #80

Closed stesie closed 10 years ago

stesie commented 10 years ago
<?php

$v8js = new V8Js();

$foo = $v8js->executeString("String.fromCharCode(65)");
var_dump($foo);

$foo = $v8js->executeString("String.fromCharCode(0)");
var_dump($foo);

Since both JS and PHP can handle strings with NULL-bytes I would expect even the latter to return a string of one byte length, ... well but:

string(1) "A"
string(0) ""
rosmo commented 10 years ago

This should fix this issue: https://github.com/rosmo/v8js/commit/3b6390b7f85ca5ccb3a5e661b9df86dc52c9bbdf