summaryrefslogtreecommitdiffstats
path: root/src/net/tcp/httpcore.c
diff options
context:
space:
mode:
authorMichael Brown2021-11-12 00:31:23 +0100
committerMichael Brown2021-11-12 10:58:29 +0100
commit1844aacc837bf81cb1959fa65f2e52dcc70a0cae (patch)
tree8ad8156c38473e608269251518c125a8cb0bda5d /src/net/tcp/httpcore.c
parent[xhci] Allow for permanent failure of the command mechanism (diff)
downloadipxe-1844aacc837bf81cb1959fa65f2e52dcc70a0cae.tar.gz
ipxe-1844aacc837bf81cb1959fa65f2e52dcc70a0cae.tar.xz
ipxe-1844aacc837bf81cb1959fa65f2e52dcc70a0cae.zip
[uri] Retain original encodings for path, query, and fragment fields
iPXE decodes any percent-encoded characters during the URI parsing stage, thereby allowing protocol implementations to consume the raw field values directly without further decoding. When reconstructing a URI string for use in an HTTP request line, the percent-encoding is currently reapplied in a reversible way: we guarantee that our reconstructed URI string could be decoded to give the same raw field values. This technically violates RFC3986, which states that "URIs that differ in the replacement of a reserved character with its corresponding percent-encoded octet are not equivalent". Experiments show that several HTTP server applications will attach meaning to the choice of whether or not a particular character was percent-encoded, even when the percent-encoding is unnecessary from the perspective of parsing the URI into its component fields. Fix by storing the originally encoded substrings for the path, query, and fragment fields and using these original encoded versions when reconstructing a URI string. The path field is also stored as a decoded string, for use by protocols such as TFTP that communicate using raw strings rather than URI-encoded strings. All other fields (such as the username and password) continue to be stored only in their decoded versions since nothing ever needs to know the originally encoded versions of these fields. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/tcp/httpcore.c')
-rw-r--r--src/net/tcp/httpcore.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/net/tcp/httpcore.c b/src/net/tcp/httpcore.c
index 01bb496b..fd94b5f0 100644
--- a/src/net/tcp/httpcore.c
+++ b/src/net/tcp/httpcore.c
@@ -614,8 +614,8 @@ int http_open ( struct interface *xfer, struct http_method *method,
/* Calculate request URI length */
memset ( &request_uri, 0, sizeof ( request_uri ) );
- request_uri.path = ( uri->path ? uri->path : "/" );
- request_uri.query = uri->query;
+ request_uri.epath = ( uri->epath ? uri->epath : "/" );
+ request_uri.equery = uri->equery;
request_uri_len =
( format_uri ( &request_uri, NULL, 0 ) + 1 /* NUL */);