leapp-repository/0045-repofileutils-disable-ConfigParser-interpolation-whe.patch
Matej Matuska b31dbfa161 IPU 8.10 -> 9.9: CTC2 candidate 1
- Requires leapp-framework 6.6+
- Initial implementation of upgrades on systems with configured Software RAID
- Handle multipath device identification in upgrade environment
- Fix upgrade incorrectly resuming during SELinux relabeling
- Fix upgrades on systems with multiple LUKS devices
- Fix upgrades for systems with /boot/efi on a Software RAID
- Fix mount failures for FSTAB entries with the `nofail` option specified
- Fix AVC errors triggered by registration to insight-client during the upgrade
- Install the correct kernel for the source system kernel page size on ARM systems
- Inhibit the upgrade when network devices configured with ifcfg files could depend on NM
- Introduce rhui.obsolete_gpg_keys configuration option for the removal of obsoleted RPM GPG keys of RHUI Cloud providers
- LiveMode: Fix upgrade getting stuck when the `.leapp_upgrade_failed` file exists
- LiveMode: Fix system version determination in the upgrade environment on CentOS Stream
- Fix target system initramfs containing outdated configuration files in some circumstances
- Ensure SELinux is set to permissive mode during the upgrade even when enforcing=1 is set on the kernel cmdline
- Fix source and target distribution names in /etc/migration-results
- Fix upgrades with the RealTime kernel on CentOS Stream
- Detect misconfigured kernel & systemd API mountpoints in FSTAB
- Detect misconfigured /var/run on the source system
- Unify behaviour of upgrades on systems with enabled CRB repositories and explicitly required CRB repositories by user during the upgrade
- Drop the inconsistent report about the use of CRB (unsupported by Red Hat) repositories
- Fix upgrade crashing when dnf repofiles contain URL encoded characters

- Resolves: RHEL-3289, RHEL-17842, RHEL-36249, RHEL-56040, RHEL-56176, RHEL-60060, RHEL-76846, RHEL-104384, RHEL-145136, RHEL-148631, RHEL-162192, RHEL-185508
2026-06-29 13:26:50 +02:00

73 lines
3.0 KiB
Diff

From 97bdaa4d90bdbb951de9d920036d93c08579bf2e Mon Sep 17 00:00:00 2001
From: Pradeep Jagtap <prjagtap@redhat.com>
Date: Fri, 17 Apr 2026 16:56:28 +0530
Subject: [PATCH 045/108] repofileutils: disable ConfigParser interpolation
when parsing .repo files
This occurs when parsing repository definitions containing percent-encoded
values (e.g. '%252B'in baseurls). Python's ConfigParser enables
interpolation by default and treats '%' as a special token, which causes
valid URLs to fail during parsing.
Disable interpolation by using parse_config(..., no_interpolation=True)
so that repository values are handled literally, consistent with DNF/YUM
behavior.
Jira-ref: RHEL-162328
---
.../common/libraries/repofileutils.py | 2 +-
repos/system_upgrade/common/libraries/utils.py | 14 ++++++++++++--
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/repos/system_upgrade/common/libraries/repofileutils.py b/repos/system_upgrade/common/libraries/repofileutils.py
index d8e087c1..4518b091 100644
--- a/repos/system_upgrade/common/libraries/repofileutils.py
+++ b/repos/system_upgrade/common/libraries/repofileutils.py
@@ -48,7 +48,7 @@ def parse_repofile(repofile):
"""
data = []
with open(repofile, mode='r') as fp:
- cp = utils.parse_config(fp, strict=False)
+ cp = utils.parse_config(fp, strict=False, no_interpolation=True)
for repoid in cp.sections():
try:
data.append(_parse_repository(repoid, dict(cp.items(repoid))))
diff --git a/repos/system_upgrade/common/libraries/utils.py b/repos/system_upgrade/common/libraries/utils.py
index b7aa9c74..bd5337c5 100644
--- a/repos/system_upgrade/common/libraries/utils.py
+++ b/repos/system_upgrade/common/libraries/utils.py
@@ -10,7 +10,7 @@ from leapp.libraries.stdlib import api, CalledProcessError, config, run, STDOUT
from leapp.utils.deprecation import deprecated
-def parse_config(cfg=None, strict=True):
+def parse_config(cfg=None, strict=True, no_interpolation=False):
"""
Applies a workaround to parse a config file using py3 AND py2
@@ -18,10 +18,20 @@ def parse_config(cfg=None, strict=True):
the old ones (Py2) obsoletes, these function was created to use the
ConfigParser on Py2 and Py3
+ When no_interpolation is True, values are read literally. Use this for
+ inputs that may contain percent-encoded URLs (e.g. yum .repo baseurl),
+ since default ConfigParser treats ``%`` as interpolation syntax.
+
:type cfg: str
:type strict: bool
+ :type no_interpolation: bool
"""
- if six.PY3:
+ if no_interpolation:
+ if six.PY3:
+ parser = six.moves.configparser.RawConfigParser(strict=strict) # pylint: disable=unexpected-keyword-arg
+ else:
+ parser = six.moves.configparser.RawConfigParser()
+ elif six.PY3:
parser = six.moves.configparser.ConfigParser(strict=strict) # pylint: disable=unexpected-keyword-arg
else:
parser = six.moves.configparser.ConfigParser()
--
2.54.0