From: krakjoe Date: Tue, 19 Nov 2013 19:10:09 +0000 (+0000) Subject: escaped strings X-Git-Tag: php-5.6.0alpha1~110^2~198 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=690a3202fd3631fec08f332f309ddc7ebd1bf942;p=php escaped strings --- diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index b03aecc246..06a32bb214 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -118,29 +118,31 @@ void phpdbg_clear_param(phpdbg_param_t *param TSRMLS_DC) /* {{{ */ } /* }}} */ -static inline phpdbg_input_t** phpdbg_read_argv(char *buffer, int *count TSRMLS_DC) /* {{{ */ +static inline phpdbg_input_t** phpdbg_read_argv(char *buffer, int *argc TSRMLS_DC) /* {{{ */ { char *p, *s; + char b[PHPDBG_MAX_CMD]; + int l=0; enum states { IN_BETWEEN, IN_WORD, IN_STRING } state = IN_BETWEEN; - phpdbg_input_t **inputs; + phpdbg_input_t **argv = NULL; + + argv = (phpdbg_input_t**) emalloc(sizeof(phpdbg_input_t**)); + (*argc) = 0; - (*count) = 0; - inputs = (phpdbg_input_t**) emalloc( - sizeof(phpdbg_input_t*) * 1); - #define RESET_STATE() do {\ phpdbg_input_t *next = emalloc(sizeof(phpdbg_input_t));\ if (next) {\ - next->string = estrndup(\ - s, ((p-1) - s)+1);\ - inputs[(*count)++] = next;\ + b[l]=0;\ + next->string = estrndup(b, l);\ + argv[(*argc)++] = next;\ + l=0;\ }\ state = IN_BETWEEN;\ -} while(0); +} while(0) for (p = buffer; *p != '\0'; p++) { int c = (unsigned char) *p; @@ -156,17 +158,26 @@ static inline phpdbg_input_t** phpdbg_read_argv(char *buffer, int *count TSRMLS_ } state = IN_WORD; s = p; + b[l++]=c; continue; case IN_STRING: - if (c == '"') { + if ((c == '"')) { + if (buffer[(p - buffer)-1] == '\\') { + b[l-1]=c; + continue; + } RESET_STATE(); + } else { + b[l++]=c; } continue; case IN_WORD: if (isspace(c)) { RESET_STATE(); + } else { + b[l++]=c; } continue; } @@ -182,7 +193,7 @@ static inline phpdbg_input_t** phpdbg_read_argv(char *buffer, int *count TSRMLS_ break; } - return inputs; + return argv; } /* }}} */ phpdbg_input_t* phpdbg_read_input(TSRMLS_D) /* {{{ */