Commit de9a76b9 by Edward Thomson

config: properly handle multiline quotes

Pass a pointer to the quote counts so that we can increment it.
parent b882e9e7
......@@ -279,8 +279,7 @@ static int skip_bom(git_parse_ctx *parser)
*/
/* '\"' -> '"' etc */
static int unescape_line(
char **out, bool *is_multi, const char *ptr, int quote_count)
static int unescape_line(char **out, bool *is_multi, const char *ptr, int *quote_count)
{
char *str, *fixed, *esc;
size_t ptr_len = strlen(ptr), alloc_len;
......@@ -296,7 +295,8 @@ static int unescape_line(
while (*ptr != '\0') {
if (*ptr == '"') {
quote_count++;
if (quote_count)
(*quote_count)++;
} else if (*ptr != '\\') {
*fixed++ = *ptr;
} else {
......@@ -358,7 +358,7 @@ static int parse_multiline_variable(git_config_parser *reader, git_str *value, i
goto next;
if ((error = unescape_line(&proc_line, &multiline,
line, in_quotes)) < 0)
line, &in_quotes)) < 0)
goto out;
/* Add this line to the multiline var */
......@@ -445,7 +445,7 @@ static int parse_variable(git_config_parser *reader, char **var_name, char **var
while (git__isspace(value_start[0]))
value_start++;
if ((error = unescape_line(&value, &multiline, value_start, 0)) < 0)
if ((error = unescape_line(&value, &multiline, value_start, NULL)) < 0)
goto out;
if (multiline) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment