dovecot-2.0-sslstream: settings parser: Warn if a line has '#' c...

dovecot at dovecot.org dovecot at dovecot.org
Sat Feb 13 02:55:15 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0-sslstream/rev/5bdae566e0dc
changeset: 10105:5bdae566e0dc
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Oct 20 14:12:55 2009 -0400
description:
settings parser: Warn if a line has '#' character not preceded by whitespace.
This should help with people trying to give '#' character in e.g. a
password and wondering why it's not working.

diffstat:

2 files changed, 16 insertions(+), 3 deletions(-)
src/config/config-parser.c  |   13 ++++++++++---
src/lib-settings/settings.c |    6 ++++++

diffs (53 lines):

diff -r f3cdf16a31a5 -r 5bdae566e0dc src/config/config-parser.c
--- a/src/config/config-parser.c	Tue Oct 20 13:21:13 2009 -0400
+++ b/src/config/config-parser.c	Tue Oct 20 14:12:55 2009 -0400
@@ -414,8 +414,8 @@ enum config_line_type {
 };
 
 static enum config_line_type
-config_parse_line(char *line, string_t *full_line, const char **key_r,
-		  const char **value_r)
+config_parse_line(struct parser_context *ctx, char *line, string_t *full_line,
+		  const char **key_r, const char **value_r)
 {
 	const char *key;
 	unsigned int len;
@@ -445,6 +445,13 @@ config_parse_line(char *line, string_t *
 			if (*p == '\0')
 				break;
 		} else if (*p == '#') {
+			if (!IS_WHITE(p[-1])) {
+				i_warning("Configuration file %s line %u: "
+					  "Ambiguous '#' character in line, treating it as comment. "
+					  "Add a space before it to remove this warning.",
+					  ctx->cur_input->path,
+					  ctx->cur_input->linenum);
+			}
 			*p = '\0';
 			break;
 		}
@@ -609,7 +616,7 @@ prevfile:
 prevfile:
 	while ((line = i_stream_read_next_line(ctx.cur_input->input)) != NULL) {
 		ctx.cur_input->linenum++;
-		type = config_parse_line(line, full_line,
+		type = config_parse_line(&ctx, line, full_line,
 					 &key, &value);
 		switch (type) {
 		case CONFIG_LINE_TYPE_SKIP:
diff -r f3cdf16a31a5 -r 5bdae566e0dc src/lib-settings/settings.c
--- a/src/lib-settings/settings.c	Tue Oct 20 13:21:13 2009 -0400
+++ b/src/lib-settings/settings.c	Tue Oct 20 14:12:55 2009 -0400
@@ -227,6 +227,12 @@ prevfile:
 				if (*p == '\0')
 					break;
 			} else if (*p == '#') {
+				if (!IS_WHITE(p[-1])) {
+					i_warning("Configuration file %s line %u: "
+						  "Ambiguous '#' character in line, treating it as comment. "
+						  "Add a space before it to remove this warning.",
+						  input->path, input->linenum);
+				}
 				*p = '\0';
 				break;
 			}


More information about the dovecot-cvs mailing list