1
0
Fork 0

- improved 'percent-decoded-p'.

This commit is contained in:
cage 2020-12-28 17:33:35 +01:00
parent fb83d673f9
commit f0b6a00d6b
1 changed files with 16 additions and 3 deletions

View File

@ -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