From: gggeek Date: Sat, 20 Jan 2018 14:16:34 +0000 (+0000) Subject: finish fixes for removal of 'each'; fix html injection in demo code X-Git-Tag: 4.3.1~4 X-Git-Url: http://git.onelab.eu/?p=plcapi.git;a=commitdiff_plain;h=ed70fcf801d85f7687e3381ad549bed634962828 finish fixes for removal of 'each'; fix html injection in demo code --- diff --git a/demo/client/introspect.php b/demo/client/introspect.php index 7870a94..478d43b 100644 --- a/demo/client/introspect.php +++ b/demo/client/introspect.php @@ -61,12 +61,12 @@ if ($resp->faultCode()) { if ($val->kindOf() == "array") { foreach ($val as $x) { $ret = $x[0]; - print "" . $ret->scalarval() . " " - . $methodName->scalarval() . "("; + print "" . htmlspecialchars($ret->scalarval()) . " " + . htmlspecialchars($methodName->scalarval()) . "("; if ($x->count() > 1) { for ($k = 1; $k < $x->count(); $k++) { $y = $x[$k]; - print $y->scalarval(); + print htmlspecialchars($y->scalarval()); if ($k < $x->count() - 1) { print ", "; } diff --git a/tests/1ParsingBugsTest.php b/tests/1ParsingBugsTest.php index e85586d..e7f56db 100644 --- a/tests/1ParsingBugsTest.php +++ b/tests/1ParsingBugsTest.php @@ -614,10 +614,12 @@ and there they were.postid7414222assertequals(1, count($v1)); - $out = array('me' => array(), 'mytype' => 2, '_php_class' => null); + $out = array(array('key' => 'me', 'value' => array()), array('key' => 'mytype', 'value' => 2), array('key' => '_php_class', 'value' => null)); + + $i = 0; foreach($v1 as $key => $val) { - $expected = each($out); + $expected = $out[$i]; $this->assertequals($expected['key'], $key); if (gettype($expected['value']) == 'array') { $this->assertequals('array', gettype($val)); @@ -628,7 +630,7 @@ and there they were.postid7414222assertequals(2, count($v2)); - $out = array(0 => 'object', 1 => 'object'); + $out = array(array('key' => 0, 'value' => 'object'), array('key' => 1, 'value' => 'object')); $i = 0; foreach($v2 as $key => $val) { diff --git a/tests/benchmark.php b/tests/benchmark.php index 43cbc42..0ca9e28 100644 --- a/tests/benchmark.php +++ b/tests/benchmark.php @@ -167,7 +167,7 @@ for ($i = 0; $i < $num_tests; $i++) { for ($k = 0; $k < $l; $k++) { $val1 = $value->arraymem($k); $out = array(); - while (list($name, $val) = $val1->structeach()) { + foreach($val1 as $name => $val) { $out[$name] = array(); $m = $val->arraysize(); for ($j = 0; $j < $m; $j++) {