From: Aki Tuomi Date: Sun, 5 Apr 2015 14:42:16 +0000 (+0300) Subject: Strip # only when preceded with whitespace or start of line X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~98^2~16^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=456c2f4b653a967aaf7274924cdac44f211777a6;p=thirdparty%2Fpdns.git Strip # only when preceded with whitespace or start of line --- diff --git a/pdns/arguments.cc b/pdns/arguments.cc index 6278dadaad..664207e6b2 100644 --- a/pdns/arguments.cc +++ b/pdns/arguments.cc @@ -404,8 +404,12 @@ bool ArgvMap::preParseFile(const char *fname, const string &arg, const string& t line+=pline; // strip everything after a # - if((pos=line.find("#"))!=string::npos) - line=line.substr(0,pos); + if((pos=line.find("#"))!=string::npos) { + // make sure it's either first char or has whitespace before + // fixes issue #354 + if (pos == 0 || std::isspace(line[pos-1])) + line=line.substr(0,pos); + } // strip trailing spaces trim_right(line); @@ -457,8 +461,12 @@ bool ArgvMap::file(const char *fname, bool lax, bool included) line+=pline; // strip everything after a # - if((pos=line.find("#"))!=string::npos) - line=line.substr(0,pos); + if((pos=line.find("#"))!=string::npos) { + // make sure it's either first char or has whitespace before + // fixes issue #354 + if (pos == 0 || std::isspace(line[pos-1])) + line=line.substr(0,pos); + } // strip trailing spaces trim(line);