Skip to content
Draft
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
1 change: 1 addition & 0 deletions CHANGES/6955.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed content app directory listing generating broken links when distribution base paths contain colons.
2 changes: 1 addition & 1 deletion pulpcore/content/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ def render_html(directory_list, path="", dates=None, sizes=None):
{% else -%}
{% set size = "" -%}
{% endif -%}
<a href="{{ name|e }}">{{ name|e }}</a>{% for number in range(100 - name|e|length) %} """
<a href="./{{ name|e }}">{{ name|e }}</a>{% for number in range(100 - name|e|length) %} """
"""{% endfor %}{{ date }} {{ size }}
{% endfor -%}
</pre><hr></body>
Expand Down
12 changes: 12 additions & 0 deletions pulpcore/tests/unit/content/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<a href="./copr-pull-requests:pr:3825/">copr-pull-requests:pr:3825/</a>' in html


def test_render_html_normal_name():
"""Normal directory names should also get the './' prefix."""
html = Handler.render_html(["simple-dir/"])
assert '<a href="./simple-dir/">simple-dir/</a>' in html


@pytest.mark.asyncio
@pytest.mark.django_db
async def test_async_pull_through_add(ca1, monkeypatch, app_status):
Expand Down
Loading