From f468a3a194a908b2f864ad892af7c3da8ea6fcd3 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Mon, 12 Jan 2015 10:13:24 +0100 Subject: [PATCH] fix up our public-suffix-list filtering, add co.za and co.il manually. --- pdns/mkpubsuffixcc | 2 +- pdns/rec_channel_rec.cc | 37 +++++++++++++++++-------------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/pdns/mkpubsuffixcc b/pdns/mkpubsuffixcc index 4f197f463..be5686be7 100755 --- a/pdns/mkpubsuffixcc +++ b/pdns/mkpubsuffixcc @@ -1,7 +1,7 @@ #!/bin/sh (echo "const char* g_pubsuffix[]={"; - for a in $(grep -v "//" effective_tld_names.dat | grep \\. | egrep "^[.0-9a-z-]*$") + for a in $(grep -v "//" effective_tld_names.dat | grep \\. | egrep "^[.0-9a-z-]*$" ; echo "co.za" ; echo "co.il" ) do echo \"$a\", done diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index 03a4a9823..117c7a5ea 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -711,7 +711,6 @@ void sortPublicSuffixList() sort(g_pubs.begin(), g_pubs.end()); } - string getRegisteredName(const std::string& dom) { vector parts; @@ -721,27 +720,25 @@ string getRegisteredName(const std::string& dom) reverse(parts.begin(), parts.end()); BOOST_FOREACH(string& str, parts) { str=toLower(str); }; - pubs_t::const_iterator iter = lower_bound(g_pubs.begin(), g_pubs.end(), parts); - if(iter != g_pubs.end()) { - if(iter != g_pubs.begin()) - --iter; - - if(iter->size() < parts.size()) { - unsigned int n; - for(n=0; n < iter->size(); ++n) - if((*iter)[n] != parts[n]) - break; - if(n==iter->size()) { - string ret; - for(unsigned int n=iter->size()+1;n;++iter,--n) { - ret+=parts[n-1]+"."; - } - return ret; - } + // uk co migweb + string last; + while(!parts.empty()) { + if(parts.size()==1 || binary_search(g_pubs.begin(), g_pubs.end(), parts)) { + + string ret=last; + if(!ret.empty()) + ret+="."; + + BOOST_REVERSE_FOREACH(const std::string& p, parts) { + ret+=p+"."; + } + return ret; } + + last=parts[parts.size()-1]; + parts.resize(parts.size()-1); } - - return parts[1]+"."+parts[0]+"."; + return "??"; } static string nopFilter(const std::string& str) -- 2.40.0