1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:37:34 +00:00

LaunchServer: Ignore empty FileType / Protocol / [Launcher] config values

"Foo=" should be treated the same as "Foo" being missing.
This commit is contained in:
Linus Groh 2020-12-24 01:44:20 +01:00 committed by Andreas Kling
parent bed240d4b3
commit 0729c8ed65

View file

@ -107,8 +107,12 @@ void Launcher::load_handlers(const String& af_dir)
HashTable<String> table; HashTable<String> table;
auto config_value = af->read_entry("Launcher", key, {}); auto config_value = af->read_entry("Launcher", key, {});
for (auto& key : config_value.split(',')) for (auto& entry : config_value.split(',')) {
table.set(key.to_lowercase()); auto key = entry.trim_whitespace().to_lowercase();
if (key.is_empty())
continue;
table.set(key);
}
return table; return table;
}; };
@ -140,11 +144,17 @@ void Launcher::load_handlers(const String& af_dir)
void Launcher::load_config(const Core::ConfigFile& cfg) void Launcher::load_config(const Core::ConfigFile& cfg)
{ {
for (auto key : cfg.keys("FileType")) { for (auto key : cfg.keys("FileType")) {
m_file_handlers.set(key.to_lowercase(), cfg.read_entry("FileType", key)); auto handler = cfg.read_entry("FileType", key).trim_whitespace();
if (handler.is_empty())
continue;
m_file_handlers.set(key.to_lowercase(), handler);
} }
for (auto key : cfg.keys("Protocol")) { for (auto key : cfg.keys("Protocol")) {
m_protocol_handlers.set(key.to_lowercase(), cfg.read_entry("Protocol", key)); auto handler = cfg.read_entry("Protocol", key).trim_whitespace();
if (handler.is_empty())
continue;
m_protocol_handlers.set(key.to_lowercase(), handler);
} }
} }