summaryrefslogtreecommitdiff
path: root/src/config_file.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2012-07-20 17:52:53 +0200
committerCarlos Martín Nieto <carlos@cmartin.tk>2012-07-21 02:28:46 +0200
commit5d9cfa07ac62ad15ebb669b01e723a990450383e (patch)
tree584b11f66e5d9a7324b4ad5d9d81730d1a3ac626 /src/config_file.c
parentc8a1892e7187d8b9be81c9fbd5b2fbb172be1ee2 (diff)
downloadlibgit2-5d9cfa07ac62ad15ebb669b01e723a990450383e.tar.gz
config: escape subsection names when creating them
This allows us to set options like "some.foo\\ish.var". This closes #830
Diffstat (limited to 'src/config_file.c')
-rw-r--r--src/config_file.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/config_file.c b/src/config_file.c
index 1f3ebfca9..7ced1e5ba 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -983,9 +983,12 @@ static int write_section(git_filebuf *file, const char *key)
if (dot == NULL) {
git_buf_puts(&buf, key);
} else {
+ char *escaped;
git_buf_put(&buf, key, dot - key);
- /* TODO: escape */
- git_buf_printf(&buf, " \"%s\"", dot + 1);
+ escaped = escape_value(dot + 1);
+ GITERR_CHECK_ALLOC(escaped);
+ git_buf_printf(&buf, " \"%s\"", escaped);
+ git__free(escaped);
}
git_buf_puts(&buf, "]\n");