From f861d80b8caecc0ae42b785243bff9f2ba225058 Mon Sep 17 00:00:00 2001 From: cage Date: Tue, 23 Jun 2020 15:22:28 +0200 Subject: [PATCH] - [gemini] percent encoded query. --- quick_quicklisp.sh.in | 1 + src/gemini/client.lisp | 2 +- src/package.lisp | 3 ++- src/text-utils.lisp | 3 +++ tinmop.asd | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/quick_quicklisp.sh.in b/quick_quicklisp.sh.in index 3eae8fb..10848c6 100644 --- a/quick_quicklisp.sh.in +++ b/quick_quicklisp.sh.in @@ -122,6 +122,7 @@ install_dependency () { --eval "(ql:quickload \"cffi\")" \ --eval "(ql:quickload \"babel\")" \ --eval "(ql:quickload \"puri\")" \ + --eval "(ql:quickload \"percent-encoding\")" \ --eval "(sb-ext:quit)"; } diff --git a/src/gemini/client.lisp b/src/gemini/client.lisp index 4a0ef2d..eee51f2 100644 --- a/src/gemini/client.lisp +++ b/src/gemini/client.lisp @@ -218,7 +218,7 @@ (let* ((uri (make-gemini-uri host path query port)) (ctx (cl+ssl:make-context :verify-mode cl+ssl:+ssl-verify-none+))) (when query - (setf uri (strcat uri "?" query))) + (setf uri (strcat uri "?" (percent-encode query)))) (cl+ssl:with-global-context (ctx :auto-free-p t) (let ((socket (usocket:socket-connect host port :element-type '(unsigned-byte 8)))) (unwind-protect diff --git a/src/package.lisp b/src/package.lisp index ff88da7..ea47cfc 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -355,7 +355,8 @@ :annotated-text-symbol :annotated-text-value :box-fit-multiple-column-annotated - :collect-links)) + :collect-links + :percent-encode)) (defpackage :html-utils (:use diff --git a/src/text-utils.lisp b/src/text-utils.lisp index 2db4282..699ba8c 100644 --- a/src/text-utils.lisp +++ b/src/text-utils.lisp @@ -670,3 +670,6 @@ printed in the box column by column; in the example above the results are: results :test #'string=)) results))) + +(defun percent-encode (string) + (percent-encoding:encode string :encoding :utf-8)) diff --git a/tinmop.asd b/tinmop.asd index 24ab576..cba60bf 100644 --- a/tinmop.asd +++ b/tinmop.asd @@ -50,6 +50,7 @@ :usocket :babel :puri + :percent-encoding :uiop) :components ((:file "package") (:file "config")