From a73b03edea9b988e079b3c8c2018321e834ff78f Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Thu, 12 May 2016 02:28:57 +0000 Subject: [PATCH] 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. --- Zend/tests/ast_serialize_backtick_literal.phpt | 11 +++++++++++ Zend/zend_ast.c | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 Zend/tests/ast_serialize_backtick_literal.phpt diff --git a/Zend/tests/ast_serialize_backtick_literal.phpt b/Zend/tests/ast_serialize_backtick_literal.phpt new file mode 100644 index 0000000000..03bdc298ac --- /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-- +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; -- 2.40.0