diff --git a/source/common/UnicodeStrings.h b/source/common/UnicodeStrings.h index ba802810..70c99d11 100644 --- a/source/common/UnicodeStrings.h +++ b/source/common/UnicodeStrings.h @@ -153,13 +153,13 @@ namespace Str { } // TODO: implement `TrimUtf8()`! -/// @param start Pointer to first character -/// @param end Pointer to after-the-last character +/// @param start Pointer to first character (or NUL-terminating character if the string is empty) +/// @param end Pointer to after-the-last character (the NUL-terminating character) inline void TrimAscii(char *&start, char *&end) { while ((start != end) && IsWhitespaceAscii(*start)) ++start; - while ((start != (end - 1)) && IsWhitespaceAscii(*(end - 1))) + while ((start != end) && IsWhitespaceAscii(*(end - 1))) --end; } diff --git a/source/server/config.cpp b/source/server/config.cpp index c01ad923..8e63fcd8 100644 --- a/source/server/config.cpp +++ b/source/server/config.cpp @@ -519,6 +519,10 @@ namespace Config { char *key_start = line_buf; char *val_end = line_buf + strlen(line_buf); Str::TrimAscii(key_start, val_end); // In-out + + if (key_start == val_end) + continue; // Skip empty lines + if (*key_start == '#') continue; // Skip comment lines