Skip to content

Commit

Permalink
Don't URL decode before routing (fixes #15)
Browse files Browse the repository at this point in the history
The defservlet* macro was already decoding a second time, which was
another bug. This fixes both.

Thanks to Matus Goljer!
  • Loading branch information
skeeto committed Oct 4, 2017
1 parent 348483e commit e7775d3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions simple-httpd.el
Original file line number Diff line number Diff line change
Expand Up @@ -665,15 +665,16 @@ if it failed to parse a complete HTTP header."
(split-string argstr "&"))))

(defun httpd-parse-uri (uri)
"Split a URI into it's components. In the return, the first
element is the script path, the second is an alist of
variable/value pairs, and the third is the fragment."
"Split a URI into its components.
The first element of the return value is the script path, the
second element is an alist of variable/value pairs, and the third
element is the fragment."
(let ((p1 (string-match (regexp-quote "?") uri))
(p2 (string-match (regexp-quote "#") uri))
retval)
(push (if p2 (httpd-unhex (substring uri (1+ p2)))) retval)
(push (if p1 (httpd-parse-args (substring uri (1+ p1) p2))) retval)
(push (httpd-unhex (substring uri 0 (or p1 p2))) retval)))
(push (substring uri 0 (or p1 p2)) retval)))

;; Path handling

Expand Down

0 comments on commit e7775d3

Please sign in to comment.