From: plugd Date: Wed, 4 Aug 2021 13:58:19 +0000 (+0200) Subject: Bug fix in gemini path normalization code. X-Git-Tag: v3.3.0~24 X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=commitdiff_plain;h=88f19dc9704f8e44316715b31c12154be7c1deaa Bug fix in gemini path normalization code. --- diff --git a/ISSUES.org b/ISSUES.org index 02c18fe..b1556a0 100644 --- a/ISSUES.org +++ b/ISSUES.org @@ -4,8 +4,30 @@ * Open Bugs -** OPEN Relative Gemini links processed improperly +** OPEN Sanitize certificate names + :LOGBOOK: + - State "OPEN" from [2020-06-22 Mon 10:32] + :END: + +Currently things will break in undefined ways if a name is specified +that contains path separators and probably other characters that I +haven't thought of. This is dangerously unacceptable and needs to be +fixed right away. + +** OPEN Set timer after creating network process + +While the current order is necessary for synchronous socks +connections, it is unecessary for regular connections which have the +no-wait flag set. Furthermore, for these connections, having the +timer fire up early means that it interferes with requests for +user interaction that may appear during the initial connection setup. +E.g., asking for approval of uknown TLS certificates. + +* Closed Bugs + +** CLOSED Relative Gemini links processed improperly :LOGBOOK: +- State "CLOSED" from "OPEN" [2021-08-04 Wed 15:54] - State "OPEN" from [2021-08-04 Wed 13:53] :END: @@ -29,26 +51,6 @@ The fix will be to ensure gemini://skyjake.fi/gemlog/.. collapses to gemini://skyjake.fi/ rather than gemini://skyjake.fi. -** OPEN Sanitize certificate names - :LOGBOOK: - - State "OPEN" from [2020-06-22 Mon 10:32] - :END: - -Currently things will break in undefined ways if a name is specified -that contains path separators and probably other characters that I -haven't thought of. This is dangerously unacceptable and needs to be -fixed right away. - -** OPEN Set timer after creating network process - -While the current order is necessary for synchronous socks -connections, it is unecessary for regular connections which have the -no-wait flag set. Furthermore, for these connections, having the -timer fire up early means that it interferes with requests for -user interaction that may appear during the initial connection setup. -E.g., asking for approval of uknown TLS certificates. - -* Closed Bugs ** CLOSED Org mode faces are not present in recent emacs versions Even 26.1 doesn't seem to have these. This means that, for many diff --git a/elpher.el b/elpher.el index 2e3c5ec..bd9cbb5 100644 --- a/elpher.el +++ b/elpher.el @@ -1429,17 +1429,22 @@ Returns the url portion in the event that the display-string portion is empty." rest)))) (defun elpher-collapse-dot-sequences (filename) - "Collapse dot sequences in FILENAME. -For instance, the filename /a/b/../c/./d will reduce to /a/c/d" - (let* ((path (split-string filename "/")) + "Collapse dot sequences in the (absolute) FILENAME. +For instance, the filename \"/a/b/../c/./d\" will reduce to \"/a/c/d\"" + (let* ((path (split-string filename "/" t)) (path-reversed-normalized (seq-reduce (lambda (a b) - (cond ((and a (equal b "..") (cdr a))) - ((and (not a) (equal b "..")) a) ;leading .. are dropped + (cond ((equal b "..") (cdr a)) ((equal b ".") a) (t (cons b a)))) - path nil))) - (string-join (reverse path-reversed-normalized) "/"))) + path nil)) + (path-normalized (reverse path-reversed-normalized))) + (if path-normalized + (concat + "/" + (string-join (reverse path-reversed-normalized) "/") + (if (string-match-p (rx (: (or "." ".." "/") line-end)) filename) "/") "") + "/"))) (defun elpher-address-from-gemini-url (url) "Extract address from URL with defaults as per gemini map files.