提交 6f71686e 编写于 作者: J Johannes Schindelin 提交者: Junio C Hamano

config_set_multivar(): disallow newlines in keys

This will no longer work:

$ git repo-config 'key.with
newline' some-value
Signed-off-by: NJohannes Schindelin <Johannes.Schindelin@gmx.de>
上级 d23842fd
......@@ -661,6 +661,11 @@ int git_config_set_multivar(const char* key, const char* value,
goto out_free;
}
c = tolower(c);
} else if (c == '\n') {
fprintf(stderr, "invalid key (newline): %s\n", key);
free(store.key);
ret = 1;
goto out_free;
}
store.key[i] = c;
}
......
......@@ -418,5 +418,11 @@ EOF
test_expect_success 'quoting' 'cmp .git/config expect'
test_expect_failure 'key with newline' 'git repo-config key.with\\\
newline 123'
test_expect_success 'value with newline' 'git repo-config key.sub value.with\\\
newline'
test_done
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册