config_parser: Allow equal sign as a separator and eat up trailing whitespace
Probably fixes T210 Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Этот коммит содержится в:
родитель
fecdc3cc0e
Коммит
1ba6ef689f
@ -76,7 +76,8 @@ out:
|
||||
char *ssh_config_get_token(char **str)
|
||||
{
|
||||
register char *c;
|
||||
char *r;
|
||||
bool had_equal = false;
|
||||
char *r = NULL;
|
||||
|
||||
/* Ignore leading spaces */
|
||||
for (c = *str; *c; c++) {
|
||||
@ -88,24 +89,36 @@ char *ssh_config_get_token(char **str)
|
||||
/* If we start with quote, return the whole quoted block */
|
||||
if (*c == '\"') {
|
||||
for (r = ++c; *c; c++) {
|
||||
if (*c == '\"') {
|
||||
if (*c == '\"' || *c == '\n') {
|
||||
*c = '\0';
|
||||
c++;
|
||||
break;
|
||||
}
|
||||
/* XXX Unmatched quotes extend to the end of line */
|
||||
}
|
||||
} else {
|
||||
/* Otherwise terminate on space, equal or newline */
|
||||
for (r = c; *c; c++) {
|
||||
if (*c == '\0') {
|
||||
goto out;
|
||||
} else if (isblank(*c) || *c == '=' || *c == '\n') {
|
||||
had_equal = (*c == '=');
|
||||
*c = '\0';
|
||||
c++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Otherwise terminate on space, equal or newline */
|
||||
for (r = c; *c; c++) {
|
||||
if (isblank(*c) || *c == '=' || *c == '\n') {
|
||||
*c = '\0';
|
||||
goto out;
|
||||
/* Skip any other remaining whitespace */
|
||||
while (isblank(*c) || *c == '\n' || (!had_equal && *c == '=')) {
|
||||
if (*c == '=') {
|
||||
had_equal = true;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
|
||||
out:
|
||||
*str = c + 1;
|
||||
|
||||
*str = c;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user