From: Christian Hofstaedtler Date: Fri, 7 Feb 2014 14:09:35 +0000 (+0100) Subject: API: Fix trailing dot handling in zonename to id helpers X-Git-Tag: rec-3.6.0-rc1~189^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=161a8b69bbdd372151fa9dd981b052443dc9e412;p=thirdparty%2Fpdns.git API: Fix trailing dot handling in zonename to id helpers --- diff --git a/pdns/ws-api.cc b/pdns/ws-api.cc index 49d9cdfdbc..d47dd1e6d6 100644 --- a/pdns/ws-api.cc +++ b/pdns/ws-api.cc @@ -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.