config_set_multivar(): disallow newlines in keys
This will no longer work: $ git repo-config 'key.with newline' some-value Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Johannes Schindelin committed
Jan 20, 2007 at 02:25 UTC
6f71686e0bac2337cdaf9057893a16a47e7d1033
2 files changed
+11
config.c
+5
@@ -661,6 +661,11 @@ int git_config_set_multivar(const char* key, const char* value,
661
goto out_free;
662
}
663
c = tolower(c);
664
+ } else if (c == '\n') {
665
+ fprintf(stderr, "invalid key (newline): %s\n", key);
666
+ free(store.key);
667
+ ret = 1;
668
+ goto out_free;
669
}
670
store.key[i] = c;
671
}
t/t1300-repo-config.sh
+6
@@ -418,5 +418,11 @@ EOF
418
419
test_expect_success 'quoting' 'cmp .git/config expect'
420
421
+test_expect_failure 'key with newline' 'git repo-config key.with\\\
422
+newline 123'
423
+
424
+test_expect_success 'value with newline' 'git repo-config key.sub value.with\\\
425
+newline'
426
+
427
test_done
428