[pacman-dev] [PATCH] ini: only recognize comments at beginning of line

Andrew Gregory andrew.gregory.8 at gmail.com
Sat Dec 17 13:18:32 UTC 2016


Allows the hash sign to be used in values in config files and hooks.

Fixes #48702

Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
---
 src/common/ini.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/common/ini.c b/src/common/ini.c
index 1ac24b5..fc834e2 100644
--- a/src/common/ini.c
+++ b/src/common/ini.c
@@ -61,19 +61,14 @@ int parse_ini(const char *file, ini_parser_fn cb, void *data)
 	}
 
 	while(safe_fgets(line, PATH_MAX, fp)) {
-		char *key, *value, *ptr;
+		char *key, *value;
 		size_t line_len;
 
 		linenum++;
 
-		/* ignore whole line and end of line comments */
-		if((ptr = strchr(line, '#'))) {
-			*ptr = '\0';
-		}
-
 		line_len = strtrim(line);
 
-		if(line_len == 0) {
+		if(line_len == 0 || line[0] == '#') {
 			continue;
 		}
 
-- 
2.10.2


More information about the pacman-dev mailing list