]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
API: Fix trailing dot handling in zonename to id helpers
authorChristian Hofstaedtler <christian@hofstaedtler.name>
Fri, 7 Feb 2014 14:09:35 +0000 (15:09 +0100)
committerChristian Hofstaedtler <christian@hofstaedtler.name>
Fri, 7 Feb 2014 14:10:38 +0000 (15:10 +0100)
pdns/ws-api.cc

index 49d9cdfdbc37c1ad6dfb79f8bb132bfcc99907cc..d47dd1e6d604156c34fdbc6912190d14cec9f150 100644 (file)
@@ -252,7 +252,7 @@ string apiZoneIdToName(const string& id) {
 
   // strip trailing dot
   if (zonename.substr(zonename.size()-1) == ".") {
-    zonename = zonename.substr(0, zonename.size()-1);
+    zonename.resize(zonename.size()-1);
   }
   return zonename;
 }
@@ -271,8 +271,12 @@ string apiZoneNameToId(const string& name) {
     }
   }
 
+  string id = ss.str();
+
   // add trailing dot
-  string id = ss.str() + ".";
+  if (id.substr(id.size()-1) != ".") {
+    id += ".";
+  }
 
   // special handling for the root zone, as a dot on it's own doesn't work
   // everywhere.