emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/elpher b42463a49e: Fixed an issue with parsing scheme://@h


From: ELPA Syncer
Subject: [nongnu] elpa/elpher b42463a49e: Fixed an issue with parsing scheme://@host urls.
Date: Fri, 15 Jul 2022 02:58:15 -0400 (EDT)

branch: elpa/elpher
commit b42463a49eca1f319bc1830f70295e8f127fb40b
Author: plugd <plugd@thelambdalab.xyz>
Commit: plugd <plugd@thelambdalab.xyz>

    Fixed an issue with parsing scheme://@host urls.
---
 elpher.el | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/elpher.el b/elpher.el
index 398aac28e6..1573581e24 100644
--- a/elpher.el
+++ b/elpher.el
@@ -447,17 +447,21 @@ For gopher addresses this is a combination of the 
selector type and selector."
 
 (defun elpher-address-host (address)
   "Retrieve host from ADDRESS object."
-  (let ((host-pre (url-host address)))
+  (pcase (url-host address)
     ;; The following strips out square brackets which sometimes enclose IPv6
     ;; addresses.  Doing this here rather than at the parsing stage may seem
     ;; weird, but this lets us way we avoid having to muck with both URL 
parsing
     ;; and reconstruction.  It's also more efficient, as this method is not
     ;; called during page rendering.
-    (if (and (> (length host-pre) 2)
-             (eq (elt host-pre 0) ?\[)
-             (eq (elt host-pre (- (length host-pre) 1)) ?\]))
-        (substring host-pre 1 (- (length host-pre) 1))
-      host-pre)))
+    ((rx (: "[" (let ipv6 (* (not "]"))) "]"))
+     ipv6)
+    ;; The following is a work-around for a parsing bug that causes
+    ;; URLs with empty (but not absent, see RFC 1738) usernames to have
+    ;; @ prepended to the hostname.
+    ((rx (: "@" (let rest (+ anything))))
+     rest)
+    (addr
+     addr)))
 
 (defun elpher-address-user (address)
   "Retrieve user from ADDRESS object."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]