-
-
Notifications
You must be signed in to change notification settings - Fork 465
Closed
Labels
questionIssue can be closed by providing informationIssue can be closed by providing information
Description
If I GET a url such as:
https://myserver.com/imgs/image with space.png?param=one two
the URL seen by the server is:
https://myserver.com/imgs/image%20with%20space.png?param=one%20two
The query parameters are decoded correctly, into:
param --> one two
However, the URL is still imgs/image%20with%20space.png
Shouldn't crowcpp automatically decode the URL path before it is passed to a route handler?
ie I would expect my handler to see imgs/image with space.png
Or are we expected to manually decode this?
Metadata
Metadata
Assignees
Labels
questionIssue can be closed by providing informationIssue can be closed by providing information
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
gittiver commentedon Feb 6, 2025
Crow currently does not decode the URL path.
Such a decoder could be added, but only makes sense in a few cases and adds additional runtime to request handling.
Therefore there is no plan to do the URL path decoding in crow.
paulharris commentedon Feb 6, 2025
Ok, I'm fine with this, however, is this typical for webservers? It seems like surprising behaviour.
Can we document this?
And add a nice obviously named function?
My route was coded something like:
IF this is the correct approach, then it would be nice to have a function that accepts a string and in-place decodes it.
What do you think?
gittiver commentedon Feb 6, 2025
Yo are welcome to add the function and the documentation.
paulharris commentedon Feb 7, 2025
I've pushed a PR with test case. Was trying codespaces, is there a way to run the unit tests in there?
gittiver commentedon Feb 7, 2025
https://github.com/CrowCpp/Crow/pull/993/checks
they run now, I had to approve.
paulharris commentedon Feb 7, 2025
I've forced-pushed. Do you have to re-approve each time?
gittiver commentedon Feb 7, 2025
It seems. :)
matelich commentedon Jun 27, 2025
Certainly surprised me, spent a long time assuming I was doing something wrong.
I'll be adding
url_decode
to myadd_static_dir()
, thanks!Looking at the MSVC implementation of std::string::resize made me wrinkle my nose a bit for a non-changing case, so I'm using
paulharris commentedon Jul 1, 2025
I'm curious so I looked into this ...
For non-changing it always calls _Eos()
For the non-changing case,
So it always sets size=size and then assigns the null terminator.
I guess they are trying to avoid a second test to check for == (one extra branch costs more than 2 assigns?)
libc++ also implements resize the same way:
https://github.com/llvm-mirror/libcxx/blob/78d6a7767ed57b50122a161b91f59f19c9bd0d19/include/string#L3095
libstdc++ uses a second test:
https://github.com/gcc-mirror/gcc/blob/24a041ea863721f3181e4433195e7697bf52c413/libstdc%2B%2B-v3/include/bits/basic_string.tcc#L432