etr / libhttpserver

C++ library for creating an embedded Rest HTTP server (and more)
GNU Lesser General Public License v2.1
882 stars 184 forks source link

[BUG] '+' character endpoint parsing becoming empty character #294

Closed jc-juarez closed 1 year ago

jc-juarez commented 1 year ago

I was testing some requests against the server and I found that whenever I pass a '+' character it becomes an empty string, so if I call an endpoint as follows:

GET server/{arg1}

where arg1 = "Hello+World"

The server receives such argument as "Hello World"

Does it have to do with something related to regex? How can I make it to actually receive the '+' character?

jc-juarez commented 1 year ago

I alredy tried using regex for the endpoint path as GET server/.* and still get the same result

bcsgh commented 1 year ago

I suspect that has something to do with application/x-www-form-urlencoded encoding that replaces spaces with +.

https://en.wikipedia.org/wiki/URL_encoding#The_application/x-www-form-urlencoded_type

So that might be WAI (but maybe it shouldn't do that anyway or have a flag to suppress it).

etr commented 1 year ago

Yeah. It is working as intended. The params on a GET are url encoded and "+" indicates a space unless escaped. If one is in need to pass a "+" from a client, they should escape it.