Merge pull request #28213 from azat/custom-tld-eof-fix

Fix reading of custom TLD w/o new line at EOF
This commit is contained in:
Maksim Kita 2021-08-27 10:57:16 +03:00 committed by GitHub
commit cdfdb2cd75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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');