mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Implement GH-15680: Enhance zend_dump_op_array to Properly Represent Non-Printable Characters in String Literals
Replaces GH-15730 as that PR became stale. But instead of introducing a new helper, reuse smart_str_append_escaped(), this also removes the dependency on ext/standard. Closes GH-15730. Closes GH-17277.
This commit is contained in:
parent
f0554477ae
commit
55afe8bd9b
5 changed files with 26 additions and 15 deletions
2
NEWS
2
NEWS
|
@ -14,6 +14,8 @@ PHP NEWS
|
||||||
Volker Dusch)
|
Volker Dusch)
|
||||||
. Use `clock_gettime_nsec_np()` for high resolution timer on macOS
|
. Use `clock_gettime_nsec_np()` for high resolution timer on macOS
|
||||||
if available. (timwolla)
|
if available. (timwolla)
|
||||||
|
. Implement GH-15680 (Enhance zend_dump_op_array to properly represent
|
||||||
|
non-printable characters in string literals). (nielsdos, WangYihang)
|
||||||
|
|
||||||
- Curl:
|
- Curl:
|
||||||
. Added curl_multi_get_handles(). (timwolla)
|
. Added curl_multi_get_handles(). (timwolla)
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "zend_func_info.h"
|
#include "zend_func_info.h"
|
||||||
#include "zend_call_graph.h"
|
#include "zend_call_graph.h"
|
||||||
#include "zend_dump.h"
|
#include "zend_dump.h"
|
||||||
#include "ext/standard/php_string.h"
|
#include "zend_smart_str.h"
|
||||||
|
|
||||||
void zend_dump_ht(HashTable *ht)
|
void zend_dump_ht(HashTable *ht)
|
||||||
{
|
{
|
||||||
|
@ -66,13 +66,27 @@ void zend_dump_const(const zval *zv)
|
||||||
case IS_DOUBLE:
|
case IS_DOUBLE:
|
||||||
fprintf(stderr, " float(%g)", Z_DVAL_P(zv));
|
fprintf(stderr, " float(%g)", Z_DVAL_P(zv));
|
||||||
break;
|
break;
|
||||||
case IS_STRING:;
|
case IS_STRING: {
|
||||||
zend_string *escaped_string = php_addcslashes(Z_STR_P(zv), "\"\\", 2);
|
smart_str escaped_string = {0};
|
||||||
|
smart_str_append_escaped(&escaped_string, Z_STRVAL_P(zv), Z_STRLEN_P(zv));
|
||||||
|
smart_str_0(&escaped_string);
|
||||||
|
|
||||||
fprintf(stderr, " string(\"%s\")", ZSTR_VAL(escaped_string));
|
fprintf(stderr, " string(\"");
|
||||||
|
|
||||||
zend_string_release(escaped_string);
|
/* Also escape '"' */
|
||||||
|
for (size_t i = 0; i < ZSTR_LEN(escaped_string.s); i++) {
|
||||||
|
if (ZSTR_VAL(escaped_string.s)[i] == '"') {
|
||||||
|
fprintf(stderr, "\\\"");
|
||||||
|
} else {
|
||||||
|
putc(ZSTR_VAL(escaped_string.s)[i], stderr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "\")");
|
||||||
|
|
||||||
|
smart_str_free_ex(&escaped_string, false);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case IS_ARRAY:
|
case IS_ARRAY:
|
||||||
fprintf(stderr, " array(...)");
|
fprintf(stderr, " array(...)");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -44,16 +44,14 @@ test:
|
||||||
; (lines=2, args=0, vars=0, tmps=0)
|
; (lines=2, args=0, vars=0, tmps=0)
|
||||||
; (after optimizer)
|
; (after optimizer)
|
||||||
; %s
|
; %s
|
||||||
0000 ECHO string("No match
|
0000 ECHO string("No match\n")
|
||||||
")
|
|
||||||
0001 RETURN null
|
0001 RETURN null
|
||||||
|
|
||||||
test2:
|
test2:
|
||||||
; (lines=2, args=0, vars=0, tmps=0)
|
; (lines=2, args=0, vars=0, tmps=0)
|
||||||
; (after optimizer)
|
; (after optimizer)
|
||||||
; %s
|
; %s
|
||||||
0000 ECHO string("No match
|
0000 ECHO string("No match\n")
|
||||||
")
|
|
||||||
0001 RETURN null
|
0001 RETURN null
|
||||||
No match
|
No match
|
||||||
No match
|
No match
|
||||||
|
|
|
@ -50,10 +50,8 @@ Loop::test:
|
||||||
; (lines=3, args=0, vars=0, tmps=0)
|
; (lines=3, args=0, vars=0, tmps=0)
|
||||||
; (after optimizer)
|
; (after optimizer)
|
||||||
; %sdce_009.php:4-10
|
; %sdce_009.php:4-10
|
||||||
0000 ECHO string("Start
|
0000 ECHO string("Start\n")
|
||||||
")
|
0001 ECHO string("Done\n")
|
||||||
0001 ECHO string("Done
|
|
||||||
")
|
|
||||||
0002 RETURN null
|
0002 RETURN null
|
||||||
|
|
||||||
Loop::test2:
|
Loop::test2:
|
||||||
|
|
|
@ -36,8 +36,7 @@ $_main:
|
||||||
0004 INIT_FCALL 1 %d string("var_export")
|
0004 INIT_FCALL 1 %d string("var_export")
|
||||||
0005 SEND_VAR CV0($x) 1
|
0005 SEND_VAR CV0($x) 1
|
||||||
0006 DO_ICALL
|
0006 DO_ICALL
|
||||||
0007 ECHO string("
|
0007 ECHO string("\n")
|
||||||
")
|
|
||||||
0008 JMP 0003
|
0008 JMP 0003
|
||||||
0009 FE_FREE V1
|
0009 FE_FREE V1
|
||||||
0010 RETURN int(1)
|
0010 RETURN int(1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue