Philipp Hörist pushed to branch httpupload at gajim / gajim


Commits:
7bcc8128 by Philipp Hörist at 2025-10-29T23:49:44+01:00
imprv: HTTPUpload: Improve support for .onion domains

Don’t enforce https for onion domains

- - - - -


1 changed file:

- gajim/common/modules/httpupload.py


Changes:

=====================================
gajim/common/modules/httpupload.py
=====================================
@@ -201,6 +201,22 @@ def _on_cancel_upload(self,
 
         obj.cancel()
 
+    @staticmethod
+    def _uri_is_acceptable(uri: str | None) -> bool:
+        if not uri:
+            return False
+
+        parts = urlparse(uri)
+        if parts.scheme not in ("http", "https"):
+            return False
+
+        # Remove port
+        domain = parts.netloc.split(":", maxsplit=1)[0]
+        if domain.endswith(".onion"):
+            return True
+
+        return parts.scheme != "http"
+
     def _received_slot(self, task: Task) -> None:
         transfer = cast(HTTPFileTransfer, task.get_user_data())
 
@@ -226,8 +242,8 @@ def _received_slot(self, task: Task) -> None:
 
         transfer.process_result(result)
 
-        if (urlparse(transfer.put_uri).scheme != 'https' or
-                urlparse(transfer.get_uri).scheme != 'https'):
+        if (self._uri_is_acceptable(transfer.put_uri) or
+                self._uri_is_acceptable(transfer.get_uri)):
             transfer.set_error('unsecure')
             return
 



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/7bcc8128f8c24f8bdb52cb4ee61ace8fbf99b7da

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/7bcc8128f8c24f8bdb52cb4ee61ace8fbf99b7da
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to