Commits

Anonymous committed 6f71686

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>

Comments (0)

Files changed (2)

 				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;
 	}

t/t1300-repo-config.sh

 
 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