1

Topic: [BUG]Wrong parsing of quotes

I found bag in file src/engine/e_console.c in function console_parse_args.
This function is used to parse params for commands. But it can't recognize commands with quotes properly.
For example:

some_command "param1" "param2 text after spaces" "param3"

parsing of this code will fail after first param.
The problem is in this part of code:

99                            /* add token */
100                            if(*str == '"')
101                            {
102                                    char *dst;
103                                    str++;
104                                    result->args[result->num_args++] = str;
105                                   
106                                    dst = str; /* we might have to process escape data */
107                                    while(1)
108                                    {
109                                            if(str[0] == '"')
110                                                    break;
111                                            else if(str[0] == '\\')
112                                            {
113                                                    if(str[1] == '\\')
114                                                            str++; /* skip due to escape */
115                                                    else if(str[1] == '"')
116                                                            str++; /* skip due to escape */
117                                            }
118                                            else if(str[0] == 0)
119                                                    return 1; /* return error */
120                                                   
121                                            *dst = *str;
122                                            dst++;
123                                            str++;
124                                    }
125                                   
126                                    /* write null termination */
127                                    *dst = 0;
128                            }

My solution is to add str++:

107                                    while(1)
108                                    {
109                                            if(str[0] == '"')
110                                            {
111                                                    str++;
112                                                    break;
113                                            }
114                                            else if(str[0] == '\\')
115                                            {

2

Re: [BUG]Wrong parsing of quotes

Patch for revision 2222: http://dl.dropbox.com/u/1691759/quote_parse.patch