Permalink
Browse files

Strip # only when preceded with whitespace or start of line

  • Loading branch information...
1 parent f55d577 commit e82da977aba01b87c793b3a87a1367cdbb817623 @cmouse cmouse committed Apr 5, 2015
Showing with 12 additions and 4 deletions.
  1. +12 −4 pdns/arguments.cc
View
@@ -401,8 +401,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);
@@ -453,8 +457,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);

0 comments on commit e82da97

Please sign in to comment.