From ff8b8f51759993dd2edded8f1a34feba9ed3d07c Mon Sep 17 00:00:00 2001 From: Jan Vidar Krey Date: Mon, 16 Aug 2010 22:53:16 +0200 Subject: [PATCH] Fix bug #139: Unable to use TLS - due to not handling quotes around configuration strings. Conflicts: src/util/misc.c --- src/core/config.c | 1 + src/util/misc.c | 21 +++++++++++++++++++++ src/util/misc.h | 1 + 3 files changed, 23 insertions(+) diff --git a/src/core/config.c b/src/core/config.c index b291431..efcce84 100644 --- a/src/core/config.c +++ b/src/core/config.c @@ -110,6 +110,7 @@ static int config_parse_line(char* line, int line_count, void* ptr_data) key = strip_white_space(key); data = strip_white_space(data); + data = strip_off_quotes(data); if (!*key || !*data) { diff --git a/src/util/misc.c b/src/util/misc.c index c670638..44ebdd5 100644 --- a/src/util/misc.c +++ b/src/util/misc.c @@ -483,3 +483,24 @@ int string_to_boolean(const char* str, int* boolean) return 0; } } + +char* strip_off_quotes(char* line) +{ + size_t len; + + if (!*line) + return line; + + len = strlen(line); + if (len < 2) + return line; + + if ((line[0] == '"' && line[len - 1] == '"') || + (line[0] == '\'' && line[len - 1] == '\'')) + { + line[len-1] = '\0'; + return line + 1; + } + return line; +} + diff --git a/src/util/misc.h b/src/util/misc.h index 048ee56..10eb967 100644 --- a/src/util/misc.h +++ b/src/util/misc.h @@ -34,6 +34,7 @@ extern void base32_encode(const unsigned char* buffer, size_t len, char* result) extern void base32_decode(const char* src, unsigned char* dst, size_t len); extern char* strip_white_space(char* string); extern void strip_off_ini_line_comments(char* line, int line_count); +extern char* strip_off_quotes(char* line); extern int file_read_lines(const char* file, void* data, file_line_handler_t handler);