testillano / h2agent

C++ HTTP/2 Mock Service which enables mocking HTTP/2 applications (also HTTP/1 supported).
Other
10 stars 0 forks source link

Fix query parameters interpretation #84

Closed testillano closed 1 year ago

testillano commented 1 year ago

Describe the bug Generally, when decoding query parameters in an HTTP request,
only the values of each parameter are decoded and not the
entire URL. This is because decoding the entire URL could
affect the structure of the URL, including characters like
"/", "?" and "&", which can have special meanings in a URL.

Query parameter values are often encoded using URL encoding,
which replaces special characters with escape sequences that
begin with the "%" symbol. For example, the "/" character
is encoded as "%2F" in URL encoding.

To decode query parameter values, URL decoding is used,
which converts escape sequences back to their original
characters. URL decoding is a standard operation that is
performed automatically in most programming languages and
web frameworks when accessing query parameter values.

In summary, in an HTTP request, only the values of query
parameters are decoded using URL decoding, and not the entire URL.

Expected behavior So, we must respect query parameters raw part and only decode
values extrated. We also add traces to query parameters extraction
function to better monitor what's happening.

This fix enables server_data helper function (and its urlencoder
for requestURI) to work properly.