com php-src: Fix serializing ZEND_AST_SHELL_EXEC: Zen d/tests/ast_serialize_backtick_literal.phpt Zend/zend _ast.c
| From: | Sara Golemon | Date: | Thu, 12 May 2016 02:47:56 +0000 |
| Subject: | com php-src: Fix serializing ZEND_AST_SHELL_EXEC: Zen d/tests/ast_serialize_backtick_literal.phpt Zend/zend _ast.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-92095@lists.php.net to get a copy of this message | ||
Commit: a73b03edea9b988e079b3c8c2018321e834ff78f
Author: Sara Golemon <pollita@php.net> Thu, 12 May 2016 02:28:57 +0000
Parents: 414eb834604c87bacf8ccc9b2b2a7695a3ccda64
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a73b03edea9b988e079b3c8c2018321e834ff78f
Log:
Fix serializing ZEND_AST_SHELL_EXEC
Currently,
foo is reserialized as 'foo' due to misuse of
zend_ast_export().
ZEND_AST_SHELL_EXEC can only contain ZEND_AST_ZVAL(string) or ZEND_AST_ENCAPS_LIST,
so just handle the ZEND_AST_ZVAL(string) case directly.
Changed paths:
A Zend/tests/ast_serialize_backtick_literal.phpt
M Zend/zend_ast.c
Diff:
diff --git a/Zend/tests/ast_serialize_backtick_literal.phpt
b/Zend/tests/ast_serialize_backtick_literal.phpt
new file mode 100644
index 0000000..03bdc29
--- /dev/null
+++ b/Zend/tests/ast_serialize_backtick_literal.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Serialization of backtick literal is incorrect
+--INI--
+zend.assertions=1
+--FILE--
+<?php
+
+assert_options(ASSERT_WARNING);
+assert(false && echo -n "");
+--EXPECTF--
+Warning: assert(): assert(false && echo -n "") failed in
%s/ast_serialize_backtick_literal.php on line 4
diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c
index 3772887...11980f1 100644
--- a/Zend/zend_ast.c
+++ b/Zend/zend_ast.c
@@ -1217,7 +1217,11 @@ simple_list:
if (ast->child[0]->kind == ZEND_AST_ENCAPS_LIST) {
zend_ast_export_encaps_list(str, '`', (zend_ast_list*)ast->child[0], indent);
} else {
- zend_ast_export_ex(str, ast->child[0], 0, indent);
+ zval *zv;
+ ZEND_ASSERT(ast->child[0]->kind == ZEND_AST_ZVAL);
+ zv = zend_ast_get_zval(ast->child[0]);
+ ZEND_ASSERT(Z_TYPE_P(zv) == IS_STRING);
+ zend_ast_export_qstr(str, '`', Z_STR_P(zv));
}
smart_str_appendc(str, '`');
break;