From c4496f6ed7c8199acef9affc7ee0af79cdf88e0d Mon Sep 17 00:00:00 2001 From: "Andre A. Gomes" Date: Mon, 5 Aug 2024 22:11:42 +0300 Subject: [PATCH 1/3] urls: Minor review. --- source/urls.lisp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/source/urls.lisp b/source/urls.lisp index f09cffa11f6..fe72d157b26 100644 --- a/source/urls.lisp +++ b/source/urls.lisp @@ -141,12 +141,12 @@ signatures." (defun valid-tld-p (hostname) "Return NIL if HOSTNAME does not include a valid TLD as determined by the Public Suffix list, T otherwise." - (sera:true (cl:ignore-errors (cl-tld:get-tld hostname)))) + (ignore-errors (cl-tld:get-tld hostname))) (export-always 'browser-schemes) (defgeneric browser-schemes (browser) (:method-combination append) - (:documentation "Return a list of schemes supported by a browser")) + (:documentation "Return a list of schemes supported by BROWSER.")) ;; Set specifier to T because *BROWSER* can be bound to NIL (defmethod browser-schemes append ((browser t)) @@ -172,11 +172,8 @@ Public Suffix list, T otherwise." (export-always 'valid-scheme-p) (defun valid-scheme-p (scheme) - "Whether the scheme is supported by Nyxt. -Usually means that either: -- SCHEME is IANA-approved, -- or SCHEME is a Nyxt-specific `scheme'." - (sera:true (find scheme (browser-schemes *browser*) :test #'string=))) + "Whether SCHEME is supported." + (find scheme (browser-schemes *browser*) :test #'string=)) (export-always 'valid-url-p) (defun valid-url-p (url &key (check-tld-p t)) From b2cac656399ba8dcefe5624dd89c33cbb737b897 Mon Sep 17 00:00:00 2001 From: "Andre A. Gomes" Date: Mon, 5 Aug 2024 22:12:08 +0300 Subject: [PATCH 2/3] urls(browser-schemes): Refactor. The special-use-schemes aren't schemes, but special-use domain names. Therefore they're out of place. --- source/urls.lisp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/source/urls.lisp b/source/urls.lisp index fe72d157b26..92172e4970e 100644 --- a/source/urls.lisp +++ b/source/urls.lisp @@ -152,23 +152,22 @@ Public Suffix list, T otherwise." (defmethod browser-schemes append ((browser t)) (let ((nyxt-schemes (append '("blob" "javascript") (alex:hash-table-keys *schemes*))) ;; List of URI schemes: https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml - ;; Last updated 2020-08-26. + ;; Last updated 2024-08-05. (iana-schemes - '("aaa" "aaas" "about" "acap" "acct" "cap" "cid" "coap" "coap+tcp" "coap+ws" - "coaps" "coaps+tcp" "coaps+ws" "crid" "data" "dav" "dict" "dns" "example" "file" - "ftp" "geo" "go" "gopher" "h323" "http" "https" "iax" "icap" "im" "imap" "info" - "ipp" "ipps" "iris" "iris.beep" "iris.lwz" "iris.xpc" "iris.xpcs" "jabber" - "ldap" "leaptofrogans" "mailto" "mid" "msrp" "msrps" "mtqp" "mupdate" "news" - "nfs" "ni" "nih" "nntp" "opaquelocktoken" "pkcs11" "pop" "pres" "reload" "rtsp" - "rtsps" "rtspu" "service" "session" "shttp" "sieve" "sip" "sips" "sms" "snmp" - "soap.beep" "soap.beeps" "stun" "stuns" "tag" "tel" "telnet" "tftp" - "thismessage" "tip" "tn3270" "turn" "turns" "tv" "urn" "vemmi" "vnc" "ws" "wss" - "xcon" "xcon-userid" "xmlrpc.beep" "xmlrpc.beeps" "xmpp" "z39.50r" "z39.50s")) - ;; https://www.iana.org/assignments/special-use-domain-names/special-use-domain-names.xml - ;; TODO: Remove when https://github.com/lu4nx/cl-tld/issues/2 is fixed. - (special-use-schemes - '("example" "invalid" "local" "localhost" "onion" "test"))) - (append nyxt-schemes iana-schemes special-use-schemes))) + '("aaa" "aaas" "about" "acap" "acct" "cap" "cid" "coap" "coap+tcp" + "coap+ws" "coaps" "coaps+tcp" "coaps+ws" "crid" "data" "dav" "dict" + "dns" "dtn" "example" "file" "ftp" "geo" "go" "gopher" "h323" "http" + "https" "iax" "icap" "im" "imap" "info" "ipn" "ipp" "ipps" "iris" + "iris.beep" "iris.lwz" "iris.xpc" "iris.xpcs" "jabber" "ldap" + "leaptofrogans" "mailto" "mid" "msrp" "msrps" "mt" "mtqp" "mupdate" + "mvrp" "mvrps" "news" "nfs" "ni" "nih" "nntp" "opaquelocktoken" + "pkcs11" "pop" "pres" "reload" "rtsp" "rtsps" "rtspu" "service" + "session" "shttp" "sieve" "sip" "sips" "sms" "snmp" "soap.beep" + "soap.beeps" "stun" "stuns" "tag" "tel" "telnet" "tftp" + "thismessage" "tip" "tn3270" "turn" "turns" "tv" "urn" "vemmi" "vnc" + "ws" "wss" "xcon" "xcon-userid" "xmlrpc.beep" "xmlrpc.beeps" "xmpp" + "z39.50r" "z39.50s"))) + (append nyxt-schemes iana-schemes))) (export-always 'valid-scheme-p) (defun valid-scheme-p (scheme) From 293016ca7c04be19786f175186f61383e0195468 Mon Sep 17 00:00:00 2001 From: "Andre A. Gomes" Date: Mon, 5 Aug 2024 22:14:16 +0300 Subject: [PATCH 3/3] renderer/gtk: Change behavior on invalid scheme. --- source/renderer/gtk.lisp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/renderer/gtk.lisp b/source/renderer/gtk.lisp index 40ec05e8b12..1bbae9c31cd 100644 --- a/source/renderer/gtk.lisp +++ b/source/renderer/gtk.lisp @@ -1086,8 +1086,8 @@ See `finalize-buffer'." (log:debug "Load URL in new buffer: ~a" (render-url (url request-data))) (nyxt::open-urls (list (url request-data))) (webkit:webkit-policy-decision-ignore response-policy-decision)) - ((not (valid-scheme-p (quri:uri-scheme (url request-data)))) - (uiop:launch-program (list *open-program* (quri:render-uri (url request-data))))) + ((null (valid-scheme-p (quri:uri-scheme (url request-data)))) + (log:warn "Unsupported URI scheme: ~s." (quri:uri-scheme (url request-data)))) ((not (known-type-p request-data)) (log:debug "Initiate download of ~s." (render-url (url request-data))) (webkit:webkit-policy-decision-download response-policy-decision))