mirror of
https://codeberg.org/cage/tinmop/
synced 2025-03-15 11:50:03 +01:00
- 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:
parent
66ba9d0b79
commit
1d850fffa4
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user