Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion convert2rhel/toolopts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import copy
import logging
import os
from sys import version_info

import six

Expand Down Expand Up @@ -151,7 +152,14 @@ def _parse_options_from_config(self, paths):
them.
:type paths: list[str]
"""
config_file = configparser.ConfigParser()

# The reason for using the RawConfigParser and ConfigParser with interpolation set to None is to prevent
# interpreting % as a sign for string replacement. This interpolation feature would cause convert2rhel to fail
# if the user enters the % character in the config file, for example in the RHSM password.
if version_info.major < 3:
config_file = configparser.RawConfigParser()
else:
config_file = configparser.ConfigParser(interpolation=None)
found_opts = {}

for path in reversed(paths):
Expand Down
4 changes: 2 additions & 2 deletions convert2rhel/unit_tests/toolopts/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def test_options_from_config_files_invalid_head_and_options(self, content, expec
(
"""\
[subscription_manager]
password = correct_password
password = %correct_password%
""",
{"password": "correct_password"},
{"password": "%correct_password%"},
),
(
"""\
Expand Down
Loading