diff --git a/CHANGES/6955.bugfix b/CHANGES/6955.bugfix new file mode 100644 index 00000000000..be0b25cf660 --- /dev/null +++ b/CHANGES/6955.bugfix @@ -0,0 +1 @@ +Fixed content app directory listing generating broken links when distribution base paths contain colons. diff --git a/pulpcore/content/handler.py b/pulpcore/content/handler.py index 7dec9ef0ae7..cf4e0f6d23b 100644 --- a/pulpcore/content/handler.py +++ b/pulpcore/content/handler.py @@ -570,7 +570,7 @@ def render_html(directory_list, path="", dates=None, sizes=None): {% else -%} {% set size = "" -%} {% endif -%} -{{ name|e }}{% for number in range(100 - name|e|length) %} """ +{{ name|e }}{% for number in range(100 - name|e|length) %} """ """{% endfor %}{{ date }} {{ size }} {% endfor -%}
diff --git a/pulpcore/tests/unit/content/test_handler.py b/pulpcore/tests/unit/content/test_handler.py index 8bcbfdebb92..789b4640be0 100644 --- a/pulpcore/tests/unit/content/test_handler.py +++ b/pulpcore/tests/unit/content/test_handler.py @@ -574,6 +574,18 @@ async def test_app_status_fixture_is_reusable(app_status, repeat): assert app_status +def test_render_html_colon_in_name(): + """Links with colons in the name should use './' prefix to avoid being treated as a scheme.""" + html = Handler.render_html(["copr-pull-requests:pr:3825/"]) + assert 'copr-pull-requests:pr:3825/' in html + + +def test_render_html_normal_name(): + """Normal directory names should also get the './' prefix.""" + html = Handler.render_html(["simple-dir/"]) + assert 'simple-dir/' in html + + @pytest.mark.asyncio @pytest.mark.django_db async def test_async_pull_through_add(ca1, monkeypatch, app_status):