From: Linus Torvalds Date: Tue, 11 Oct 2005 22:24:11 +0000 (-0700) Subject: Improve config file escape sanity checking X-Git-Tag: v0.99.9~149 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=5cbb401dbaff5fd810a85b84333cb0c22d264f36;p=git.git Improve config file escape sanity checking I had meant to disallow unknown escape characters in the config file parser, but instead an unknown escaped character would silently pass through as itself. That's correct for some cases (notably '\' itself), but wasn't correct in general. This fixes it, and makes the parser write a nice error message if the config file contains bogus escaped characters. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- diff --git a/config.c b/config.c index f3c4fa42..510456ce 100644 --- a/config.c +++ b/config.c @@ -64,7 +64,12 @@ static char *parse_value(void) case 'n': c = '\n'; break; - return NULL; + /* Some characters escape as themselves */ + case '\\': case '"': + break; + /* Reject unknown escape sequences */ + default: + return NULL; } value[len++] = c; continue;