You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2026/08/26 15:52:44 UTC
(allura) branch db/8621 created (now b362866a2)
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a change to branch db/8621
in repository https://gitbox.apache.org/repos/asf/allura.git
at b362866a2 [#8621] drop ftp/file/data url handlers
This branch includes the following new commits:
new b362866a2 [#8621] drop ftp/file/data url handlers
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(allura) 01/01: [#8621] drop ftp/file/data url handlers
Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch db/8621
in repository https://gitbox.apache.org/repos/asf/allura.git
commit b362866a2d1a93edbdc0af7335440fb4d4ba5df1
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Tue Aug 25 17:22:00 2026 -0400
[#8621] drop ftp/file/data url handlers
---
Allura/allura/lib/helpers.py | 18 +++++++++++++++++-
.../forgetracker/tests/unit/test_ticket_model.py | 11 ++++-------
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index 07204583f..d51057b7f 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -1115,7 +1115,23 @@ def http_open(self, req):
return super().http_open(req)
-urllib.request.install_opener(urllib.request.build_opener(NotInternalHTTPHandler, NoInternalHTTPSHandler))
+def _build_http_only_opener() -> urllib.request.OpenerDirector:
+ """Only support http(s), so a redirect can't reach ftp/file/data and skip our host checks."""
+ opener = urllib.request.OpenerDirector()
+ for handler_cls in (
+ urllib.request.ProxyHandler,
+ urllib.request.UnknownHandler,
+ urllib.request.HTTPDefaultErrorHandler,
+ urllib.request.HTTPRedirectHandler,
+ urllib.request.HTTPErrorProcessor,
+ ):
+ opener.add_handler(handler_cls())
+ opener.add_handler(NotInternalHTTPHandler())
+ opener.add_handler(NoInternalHTTPSHandler())
+ return opener
+
+
+urllib.request.install_opener(_build_http_only_opener())
def urlopen(url: str | urllib.request.Request, retries=3, codes=(408, 500, 502, 503, 504), timeout=None):
diff --git a/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py b/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
index 2afd810cc..7e1843b55 100644
--- a/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
+++ b/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
@@ -18,9 +18,6 @@
from tg import tmpl_context as c
from datetime import datetime
import os
-import six.moves.urllib.parse
-import six.moves.urllib.request
-import six.moves.urllib.error
import mock
import pytest
@@ -348,10 +345,10 @@ def test_attach_with_resettable_stream(self):
ticket.summary = 'test ticket'
ticket.description = 'test description'
assert len(ticket.attachments) == 0
- f = six.moves.urllib.request.urlopen('file://%s' % __file__) # noqa: S310
- TicketAttachment.save_attachment(
- 'test_ticket_model.py', ResettableStream(f),
- artifact_id=ticket._id)
+ with open(__file__, 'rb') as f:
+ TicketAttachment.save_attachment(
+ 'test_ticket_model.py', ResettableStream(f),
+ artifact_id=ticket._id)
ThreadLocalODMSession.flush_all()
# need to refetch since attachments are cached
session(ticket).expunge(ticket)