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


Commits:
3eed6817 by mjk at 2023-04-03T17:54:59+00:00
imprv: Make `gemini` URIs clickable

- - - - -


2 changed files:

- gajim/common/const.py
- gajim/common/helpers.py


Changes:

=====================================
gajim/common/const.py
=====================================
@@ -951,6 +951,11 @@ def is_active(self):
 GAJIM_SUPPORT_JID = '[email protected]'
 
 
+# Clickable URI schemes not (yet) registered with IANA (see ./iana.py)
+NONREGISTERED_URI_SCHEMES = {
+    'gemini',
+}
+
 # This is an excerpt of Media Types from
 # https://www.iana.org/assignments/media-types/media-types.xhtml
 # plus some additions


=====================================
gajim/common/helpers.py
=====================================
@@ -87,6 +87,7 @@
 from gajim.common import types
 from gajim.common.const import CONSONANTS
 from gajim.common.const import GIO_TLS_ERRORS
+from gajim.common.const import NONREGISTERED_URI_SCHEMES
 from gajim.common.const import SHOW_LIST
 from gajim.common.const import SHOW_STRING
 from gajim.common.const import SHOW_STRING_MNEMONIC
@@ -870,9 +871,14 @@ def func_wrapper(self, *args, **kwargs):
     return func_wrapper
 
 
-def is_registered_uri_scheme(scheme: str) -> bool:
+def is_known_uri_scheme(scheme: str) -> bool:
+    '''
+    `scheme` is lower-case
+    '''
     if scheme in iana.URI_SCHEMES:
         return True
+    if scheme in NONREGISTERED_URI_SCHEMES:
+        return True
     return scheme in app.settings.get('additional_uri_schemes').split()
 
 
@@ -913,8 +919,8 @@ def parse_uri(uri: str) -> URI:
 
     scheme = urlparts.scheme  # urlparse is expected to return it in lower case
 
-    if not is_registered_uri_scheme(scheme):
-        return URI(URIType.INVALID, uri, data={'error': 'Unregistered scheme'})
+    if not is_known_uri_scheme(scheme):
+        return URI(URIType.INVALID, uri, data={'error': 'Unknown scheme'})
 
     if scheme in ('https', 'http'):
         if not urlparts.netloc:



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/3eed6817a270c2a10cb37075c0c9b7a3b32a9415

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


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to