Skip to content

Commit

Permalink
config-manager: Fix addrepo from-repofile with empty/comment lines
Browse files Browse the repository at this point in the history
Comments and empty lines were interpreted as options
in the configuration file validity test. Now they are ignored.
  • Loading branch information
jrohel committed Sep 5, 2024
1 parent 58cfa3f commit 9cd1bc8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dnf5-plugins/config-manager_plugin/addrepo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,12 @@ void ConfigManagerAddRepoCommand::add_repos_from_repofile(
// Test if the repository options can be set.
for (const auto & [repo_id, repo_opts] : parser.get_data()) {
for (const auto & [key, key_val] : repo_opts) {
// Skip empty lines and comment lines (ConfigParser stores the empty line and comment line
// in an automatically generated key whose name starts with the '#' character).
if (key.starts_with('#')) {
continue;
}

try {
tmp_repo_conf.opt_binds().at(key).new_string(Option::Priority::RUNTIME, key_val);
} catch (const Error & ex) {
Expand Down

0 comments on commit 9cd1bc8

Please sign in to comment.