Show
Ignore:
Timestamp:
03/25/07 14:19:15 (6 years ago)
Author:
ahu
Message:

fix ticket 106 which explains we mis-parse ; in "strings"

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/zoneparser-tng.cc

    r979 r989  
    163163} 
    164164 
     165void chopComment(string& line) 
     166{ 
     167  string::size_type pos, len = line.length(); 
     168  bool inQuote=false; 
     169  for(pos = 0 ; pos < len; ++pos) { 
     170    if(line[pos]=='\\')  
     171      pos++; 
     172    else if(line[pos]=='"')  
     173      inQuote=!inQuote; 
     174    else if(line[pos]==';' && !inQuote) 
     175      break; 
     176  } 
     177  if(pos != len) 
     178    line.resize(pos); 
     179} 
     180 
    165181bool ZoneParserTNG::get(DNSResourceRecord& rr)  
    166182{ 
     
    274290  rr.content=d_line.substr(range.first); 
    275291 
    276   string::size_type pos=rr.content.rfind(';'); 
    277   if(pos!=string::npos) 
    278     rr.content.resize(pos); 
     292  chopComment(rr.content); 
     293  string::size_type pos; 
    279294 
    280295  if(rr.qtype.getCode()!=QType::TXT && (pos=rr.content.find('('))!=string::npos) { 
     
    283298    while(getLine()) { 
    284299      chomp(d_line,"\r\n "); 
    285       pos=d_line.rfind(';'); 
    286       if(pos!=string::npos) 
    287         d_line.resize(pos); 
     300      chopComment(d_line); 
    288301 
    289302      trim(d_line);