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 <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Linus Torvalds committed
Oct 11, 2005 at 15:24 UTC
5cbb401dbaff5fd810a85b84333cb0c22d264f36
1 file changed
+6
-1
config.c
+6
-1
@@ -64,7 +64,12 @@ static char *parse_value(void)
64
case 'n':
65
c = '\n';
66
break;
67
- return NULL;
67
+ /* Some characters escape as themselves */
68
+ case '\\': case '"':
69
+ break;
70
+ /* Reject unknown escape sequences */
71
+ default:
72
+ return NULL;
73
}
74
value[len++] = c;
75
continue;