1
0
mirror of https://codeberg.org/cage/tinmop/ synced 2025-02-08 07:08:39 +01:00

- fixed 'uri:normalize-path';

- [gemini] cleaned paths when exploring local tree.
This commit is contained in:
cage 2021-03-28 16:43:21 +02:00
parent e2a9016607
commit ef3724e986
3 changed files with 12 additions and 8 deletions

View File

@ -1017,8 +1017,9 @@
((gemini-client:absolute-gemini-url-p url) ((gemini-client:absolute-gemini-url-p url)
(gemini-viewer:request url :use-cached-file-if-exists use-cached-file-if-exists)) (gemini-viewer:request url :use-cached-file-if-exists use-cached-file-if-exists))
((fs:dirp url) ((fs:dirp url)
(let* ((index-path (fs:prepend-pwd url)) (let* ((index-path (uri:normalize-path (fs:prepend-pwd url)))
(all-paths (fs:collect-children index-path)) (all-paths (mapcar #'uri:normalize-path
(fs:collect-children index-path)))
(raw-text (with-output-to-string (stream) (raw-text (with-output-to-string (stream)
(write-sequence (gemini-parser:geminize-h1 (write-sequence (gemini-parser:geminize-h1
(format nil (format nil

View File

@ -75,5 +75,6 @@
(deftest test-normalize-path (uri-suite) (deftest test-normalize-path (uri-suite)
(assert-true (normalize "/a/x" "/a/x")) (assert-true (normalize "/a/x" "/a/x"))
(assert-true (normalize "/a/../b/x" "/b/x")) (assert-true (normalize "/a/../b/x" "/b/x"))
(assert-true (normalize "/a/../b/x/.." "/b/x/")) (assert-true (normalize "/a/../b/x/.." "/b/"))
(assert-true (normalize "/a/../b/x/." "/b/x/"))) (assert-true (normalize "/a/../b/x/." "/b/x/"))
(assert-true (normalize "/a/b/c/./../../g" "/a/g")))

View File

@ -349,13 +349,15 @@
(let ((popped (stack:stack-pop input-stack))) (let ((popped (stack:stack-pop input-stack)))
(cond (cond
((and (string= popped "..") ((and (string= popped "..")
(not (stack:stack-empty-p output-stack)) (not (stack:stack-empty-p output-stack)))
(not (stack:stack-empty-p input-stack))) (stack:stack-pop output-stack)
(stack:stack-pop output-stack)) (when (stack:stack-empty-p input-stack)
(setf ends-with-dots t)))
((and (or (string= popped "..") ((and (or (string= popped "..")
(string= popped ".")) (string= popped "."))
(stack:stack-empty-p input-stack)) (stack:stack-empty-p input-stack))
(setf ends-with-dots t)) (setf ends-with-dots t)
(stack:stack-push output-stack "/"))
((and (string/= popped ".") ((and (string/= popped ".")
(string/= popped "..")) (string/= popped ".."))
(stack:stack-push output-stack popped)))) (stack:stack-push output-stack popped))))