Fix reading of custom TLD w/o new line at EOF

Fixes: #28177
This commit is contained in:
Azat Khuzhin 2021-08-27 00:43:21 +03:00
parent e42b029155
commit 91621cfcd2
5 changed files with 13 additions and 1 deletions

View File

@ -64,7 +64,8 @@ size_t TLDListsHolder::parseAndAddTldList(const std::string & name, const std::s
while (!in.eof())
{
readEscapedStringUntilEOL(line, in);
++in.position();
if (!in.eof())
++in.position();
/// Skip comments
if (line.size() > 2 && line[0] == '/' && line[1] == '/')
continue;

View File

@ -1,5 +1,6 @@
<yandex>
<top_level_domains_lists>
<public_suffix_list>public_suffix_list.dat</public_suffix_list>
<no_new_line_list>no_new_line_list.dat</no_new_line_list>
</top_level_domains_lists>
</yandex>

View File

@ -0,0 +1 @@
foo.bar

View File

@ -28,3 +28,7 @@ foo
-- vector
xx.blogspot.co.at
-- no new line
foo.bar
a.foo.bar
foo.baz

View File

@ -37,3 +37,8 @@ select cutToFirstSignificantSubdomainCustom('http://www.foo', 'public_suffix_lis
select '-- vector';
select cutToFirstSignificantSubdomainCustom('http://xx.blogspot.co.at/' || toString(number), 'public_suffix_list') from numbers(1);
select cutToFirstSignificantSubdomainCustom('there-is-no-such-domain' || toString(number), 'public_suffix_list') from numbers(1);
select '-- no new line';
select cutToFirstSignificantSubdomainCustom('foo.bar', 'no_new_line_list');
select cutToFirstSignificantSubdomainCustom('a.foo.bar', 'no_new_line_list');
select cutToFirstSignificantSubdomainCustom('a.foo.baz', 'no_new_line_list');