LookupServer: Fix to handle whitespaces and tabs in /etc/hosts

This commit is contained in:
fleximus 2021-10-04 00:49:49 +02:00 committed by Andreas Kling
parent fe50598a03
commit 3115a5306d
Notes: sideshowbarker 2024-07-18 03:02:51 +09:00

View file

@ -107,7 +107,8 @@ void LookupServer::load_etc_hosts()
if (original_line.is_empty())
break;
auto trimmed_line = original_line.view().trim_whitespace();
auto fields = trimmed_line.split_view('\t', false);
auto replaced_line = trimmed_line.replace(" ", "\t", true);
auto fields = replaced_line.split_view('\t', false);
if (fields.size() < 2) {
dbgln("Failed to parse line {} from '/etc/hosts': '{}'", line_number, original_line);