[httpd] Fix parsing of uri into path parts with encoded '/' (%2F)

In path with an encoded '/' character, the parsing of the path into
parts was wrong.

E. g. an uri like
'/api/library/composers/Adam%20Gardner%2FDavid%20Schneider' would result
in the following parts:

- path_part[0] = "/api"
- path_part[1] = "library"
- path_part[2] = "composer"
- path_part[3] = "Adam Gardner"
- path_part[4] = "David Schneider"

Doing the decode after splitting the uri into parts fixes this and
results in:

- path_part[0] = "api"
- path_part[1] = "library"
- path_part[2] = "composer"
- path_part[3] = "Adam Gardner/David Schneider"
This commit is contained in:
chme
2022-03-27 08:48:46 +02:00
parent a932cc532d
commit b18b76413d
2 changed files with 21 additions and 13 deletions

View File

@@ -23,10 +23,9 @@ enum httpd_send_flags
*
* We are interested in the path and the query, so they are disassembled to
* path_parts and ev_query. If the request is http://x:3689/foo/bar?key1=val1,
* then part_parts[1] is "foo", [2] is "bar" and the rest is null (the first
* element points to the copy of the path so it can be freed).
* then part_parts[0] is "foo", [1] is "bar" and the rest is null.
*
* The allocated strings are URI decoded.
* Each path_part is an allocated URI decoded string.
*/
struct httpd_uri_parsed
{