Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] Auto-quote config values in config.c:store_write_pair()

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:42:48

Hi,

[Cc'ing list]

On Tue, 9 Jan 2007, Junio C Hamano wrote:
Johannes Schindelin [off-list ref] writes:
quoted
On Tue, 9 Jan 2007, Brian Gernhardt wrote:
quoted
+	if (quote)
+		write(fd, "\"", 1);
 	for (i = 0; value[i]; i++)
 		switch (value[i]) {
 		case '\n': write(fd, "\\n", 2); break;
@@ -508,6 +520,8 @@ static void store_write_pair(int fd, const char* key, const char* value)
 		case '"': case '\\': write(fd, "\\", 1);
 		default: write(fd, value+i, 1);
 	}
+	if (quote)
+		write(fd, "\"", 1);
AFAICS this misses the case where you have to quote a single '"'.
	$ git-repo-config qu.ot 'ab"cd'
        $ git-repo-config --get qu.ot
        ab"cd
        $ tail -n 2 .git/config
        [qu]
        	ot = ab\"cd
Oooopps! Even more embarassing: you can see it in the diff (it is line 508 
of the original code). And most embarassing: AFAICT I wrote the code 
myself!!!

So I shut up.

Ciao,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help