Skip to content

Commit 5bed823

Browse files
Mr-Taopraiskup
authored andcommitted
Decode file:// repo paths before bootstrap bind mount
Add the Towncrier release-note snippet and mention PR #1728.
1 parent bf868a6 commit 5bed823

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

mock/py/mockbuild/package_manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import time
1010
import re
11+
from urllib.parse import unquote
1112
from textwrap import dedent
1213
from configparser import ConfigParser
1314

@@ -512,6 +513,7 @@ def _bind_mount_repos_to_bootstrap(self):
512513
continue
513514

514515
srcpath = self.expand_url_vars(srcpath)
516+
srcpath = unquote(srcpath)
515517

516518
if srcpath in tried:
517519
continue

mock/tests/test_package_manager.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import tempfile
33
import shutil
4+
from pathlib import Path
45

56
import pytest
67
from unittest import mock
@@ -117,6 +118,22 @@ def test_file_colon_slash_path_name_in_baseurl(self):
117118
assert mounts[0].bindpath.startswith(self.workdir)
118119
assert mounts[0].bindpath.endswith(repo_directory)
119120

121+
def test_urlencoded_file_path_name_in_baseurl(self):
122+
repo_directory = os.path.join(self.workdir, 'repo@2')
123+
os.mkdir(repo_directory)
124+
config = """
125+
[main]
126+
something = 1
127+
128+
[fedora]
129+
baseurl = {}
130+
""".format(Path(repo_directory).as_uri())
131+
mounts = self.get_user_bind_mounts_from_config(config)
132+
assert len(mounts) == 1
133+
assert mounts[0].srcpath == repo_directory
134+
assert mounts[0].bindpath.startswith(self.workdir)
135+
assert mounts[0].bindpath.endswith(repo_directory)
136+
120137
def test_dir_doesnt_exist(self):
121138
repo_directory = os.path.join(self.workdir, 'repo')
122139
config = """
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Mock now decodes percent-escaped local `file://` repository paths before
2+
checking them for bootstrap bind mounts. This fixes bootstrap package-manager
3+
access to host-local repositories whose paths contain characters such as `@`
4+
and therefore appear escaped in file URIs, as in [PR#1728][].

0 commit comments

Comments
 (0)