com php-src: Fix ctrl characters handling: phpdbg_cmd.c p hpdbg_utils.c
| From: | Bob Weinand | Date: | Wed, 15 Oct 2014 18:30:16 +0000 |
| Subject: | com php-src: Fix ctrl characters handling: phpdbg_cmd.c p hpdbg_utils.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-82561@lists.php.net to get a copy of this message | ||
Commit: b28e3d01d77ee29fc5442d9d0b3d8f06b78b41a1
Author: Bob Weinand <bobwei9@hotmail.com> Wed, 15 Oct 2014 20:30:16 +0200
Parents: c812ee9c3556c0ea797627c86a0a650c65f9908b
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b28e3d01d77ee29fc5442d9d0b3d8f06b78b41a1
Log:
Fix ctrl characters handling
Changed paths:
M phpdbg_cmd.c
M phpdbg_utils.c
Diff:
diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c
index f649bde..ad49c62 100644
--- a/phpdbg_cmd.c
+++ b/phpdbg_cmd.c
@@ -841,6 +841,14 @@ readline:
}
for (i = len; i < len + bytes; i++) {
+ if (buf[i] == '\x03') {
+ if (i != len + bytes - 1) {
+ memmove(buf + i, buf + i + 1, len + bytes - i - 1);
+ }
+ len--;
+ i--;
+ continue;
+ }
if (buf[i] == '\n') {
PHPDBG_G(input_buflen) = len + bytes - 1 - i;
if (PHPDBG_G(input_buflen)) {
diff --git a/phpdbg_utils.c b/phpdbg_utils.c
index 27b75b2..4117887 100644
--- a/phpdbg_utils.c
+++ b/phpdbg_utils.c
@@ -1103,7 +1103,11 @@ static void phpdbg_encode_ctrl_chars(char **buf, int *buflen) {
len += 4;
*tmpptr++ = '&';
*tmpptr++ = '#';
- *tmpptr++ = ((*buf)[i] / 10) + '0';
+ if ((unsigned int) buf[i] > 10) {
+ *tmpptr++ = ((*buf)[i] / 10) + '0';
+ } else {
+ --len;
+ }
*tmpptr++ = ((*buf)[i] % 10) + '0';
*tmpptr++ = ';';
} else {
@@ -1373,6 +1377,8 @@ PHPDBG_API int phpdbg_xml_internal(int fd TSRMLS_DC, const char *fmt, ...) {
buflen = phpdbg_xml_vasprintf(&buffer, fmt, 1, args TSRMLS_CC);
va_end(args);
+ phpdbg_encode_ctrl_chars(&buffer, &buflen);
+
if (PHPDBG_G(in_script_xml)) {
write(fd, ZEND_STRL("</stream>"));
PHPDBG_G(in_script_xml) = 0;
@@ -1416,6 +1422,7 @@ PHPDBG_API int phpdbg_out_internal(int fd TSRMLS_DC, const char *fmt, ...) {
int msglen;
msglen = phpdbg_encode_xml(&msg, buffer, buflen, 256, NULL);
+ phpdbg_encode_ctrl_chars(&msg, &msglen);
if (PHPDBG_G(in_script_xml)) {
write(fd, ZEND_STRL("</stream>"));