mirror of https://codeberg.org/cage/tinmop/
- improved 'percent-decoded-p'.
This commit is contained in:
parent
fb83d673f9
commit
f0b6a00d6b
|
@ -677,10 +677,23 @@ printed in the box column by column; in the example above the results are:
|
|||
(defun percent-decode (string)
|
||||
(percent-encoding:decode string :encoding :utf-8))
|
||||
|
||||
(defun percent-decode-allow-null (data)
|
||||
(when data
|
||||
(percent-decode data)))
|
||||
|
||||
(defun percent-encoded-p (string)
|
||||
(conditions:with-default-on-error (t)
|
||||
(string/= string
|
||||
(percent-decode 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)))))
|
||||
(return-from percent-encoded-p nil))))
|
||||
t)
|
||||
|
||||
(defun percent-encode-allow-null (data)
|
||||
(when data
|
||||
|
|
Loading…
Reference in New Issue