return true;
}
+inline bool pdns_iequals_ch(const char a, const char b) __attribute__((pure));
+inline bool pdns_iequals_ch(const char a, const char b)
+{
+ if ((a != b) && (dns_tolower(a) != dns_tolower(b)))
+ return false;
+
+ return true;
+}
+
// lifted from boost, with thanks
class AtomicCounter
{
}
};
+inline size_t pdns_ci_find(const string& haystack, const string& needle)
+{
+ string::const_iterator it = std::search(haystack.begin(), haystack.end(),
+ needle.begin(), needle.end(), pdns_iequals_ch);
+ if (it == haystack.end()) {
+ // not found
+ return string::npos;
+ } else {
+ return it - haystack.begin();
+ }
+}
pair<string, string> splitField(const string& inp, char sepa);
BOOST_FOREACH(const DomainInfo& di, domains) {
string zoneId = apiZoneNameToId(di.zone);
- if (di.zone.find(q) != string::npos) {
+ if (pdns_ci_find(di.zone, q) != string::npos) {
Value object;
object.SetObject();
object.AddMember("type", "zone", doc.GetAllocator());
if (!rr.qtype.getCode())
continue; // skip empty non-terminals
- if (rr.qname.find(q) == string::npos && rr.content.find(q) == string::npos)
+ if (pdns_ci_find(rr.qname, q) == string::npos && pdns_ci_find(rr.content, q) == string::npos)
continue;
Value object;
di.backend->listComments(di.id);
while(di.backend->getComment(comment)) {
- if (comment.qname.find(q) == string::npos && comment.content.find(q) == string::npos)
+ if (pdns_ci_find(comment.qname, q) == string::npos && pdns_ci_find(comment.content, q) == string::npos)
continue;
Value object;
# should return zone, SOA, ns1, ns2
self.assertEquals(len(r.json()), 4)
+ def test_SearchRRCaseInsensitive(self):
+ name = 'search-rr-insenszone.name'
+ self.create_zone(name=name)
+ r = self.session.get(self.url("/servers/localhost/search-data?q=rr-insensZONE"))
+ self.assertSuccessJson(r)
+ print r.json()
+ # should return zone, SOA, ns1, ns2
+ self.assertEquals(len(r.json()), 4)
+
@unittest.skipIf(not isRecursor(), "Not applicable")
class RecursorZones(ApiTestCase):