From 88f19dc9704f8e44316715b31c12154be7c1deaa Mon Sep 17 00:00:00 2001 From: plugd Date: Wed, 4 Aug 2021 15:58:19 +0200 Subject: [PATCH] Bug fix in gemini path normalization code. --- ISSUES.org | 44 +++++++++++++++++++++++--------------------- elpher.el | 19 ++++++++++++------- 2 files changed, 35 insertions(+), 28 deletions(-) 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. -- 2.20.1