Query allows spaces
gibsonf1 opened this issue · 1 comments
gibsonf1 commented
I've been using (quri:uri to confirm something is a valid uri, however I just discovered that the query parse allows spaces. Is that permitted with the spec?
WEB> (quri:uri "https://github.com?bad=this is a test")
#<URI-HTTPS https://github.com?bad=this is a test>
WEB> (quri:render-uri *)
"https://github.com?bad=this is a test"
WEB>
For now I've just added a space scan:
(defmethod ?uri ((item quri.uri:uri))
(declare (optimize (speed 3) (safety 1) (debug 1)))
(let* ((scheme (quri:uri-scheme item))
(host (quri:uri-host item))
(dhost (if host (split-string #\. host)))
(query (quri:uri-query item))
)
(when (or (not query)(and query (not (ppcre:scan "\\s" query))))
(when (and (member scheme '("http" "https" "ftp") :test #'string-equal)
(or (ppcre:scan "localhost" host)
(and (> (length dhost) 1)(> (length (car (last dhost))) 1)))
)
t))))
aadcg commented
My understanding is that, according to the spec, spaces aren't unreserved characters.
But perhaps it's not quri
's goal to validate URIs.