1
0
Fork 0

- fixed text-utils:percent-encoded-p, an empty string is not percent-encoded;

- raised a better error when an empty string is entered as a gemini address.
This commit is contained in:
cage 2021-04-25 16:12:49 +02:00
parent 66ba9d0b79
commit 1d850fffa4
2 changed files with 18 additions and 13 deletions

View File

@ -1018,6 +1018,8 @@
(when give-focus-to-message-window-p
(ui:focus-to-message-window))
(cond
((text-utils:string-empty-p url)
(ui:error-message (_ "Empty address")))
((gemini-client:absolute-gemini-url-p url)
(gemini-viewer:request url :use-cached-file-if-exists use-cached-file-if-exists))
((fs:dirp local-path)

View File

@ -695,19 +695,22 @@ printed in the box column by column; in the example above the results are:
(percent-decode data)))
(defun percent-encoded-p (string)
(loop for i in (coerce string 'list)
for ct from 0 do
(cond
((char= i #\%)
(when (not (cl-ppcre:scan "(?i)^%[0123456789abcdef]{2}" string :start ct))
(return-from percent-encoded-p nil)))
((or (percent:reservedp i)
(char= i #\Space)
(not (or (percent:alphap (char-code i))
(percent:digitp (char-code i))
(percent:unreservedp (char-code i)))))
(return-from percent-encoded-p nil))))
t)
(if (string-empty-p string)
nil
(progn
(loop for i in (coerce string 'list)
for ct from 0 do
(cond
((char= i #\%)
(when (not (cl-ppcre:scan "(?i)^%[0123456789abcdef]{2}" string :start ct))
(return-from percent-encoded-p nil)))
((or (percent:reservedp i)
(char= i #\Space)
(not (or (percent:alphap (char-code i))
(percent:digitp (char-code i))
(percent:unreservedp (char-code i)))))
(return-from percent-encoded-p nil))))
t)))
(defun percent-encode-allow-null (data)
(when data