You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use URL-encoded chars in my routes and Rocket just responds with 404. Rocket manages to compile with the following test case, but the issue is that, as you can see in the log output:
GET /h%C3%A4cker:
>> No matching routes for GET /h%C3%A4cker.
>> No 404 catcher registered. Using Rocket default.
when i make the request to the exact same path as the get macro was defined as, Rocket fails to match my request to my route.
This way I've done it in the test case is a reasonable assumption to how Rocket would handle paths as according to this part of the docs, Origins should be URL-encoded.
Oh ok, so actually I realized that the test case I gave actually does match, to /h%25C3%25A4cker, which is just /h%C3%A4cker URL-encoded another time.
So what happened was when I submitted this, was that I simplified the test case in the issue so much that I actually lost the root of the problem. The real problem disappeared when moved the /häcker/ from the rocket.mount() to the get macro. Here's an example that represents more my original code:
> cargo run
Compiling rocket-unicode-issue-test v0.1.0 (/home/ludv/coding/misc/rocket-unicode-issue-test)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.29s
Running `target/debug/rocket-unicode-issue-test`
Error: invalid route base: /häcker/
>> unexpected token byte 195 at index 2
>> in src/main.rs:15:21
thread 'main' panicked at src/main.rs:15:21:
aborting due to route base error
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
So the issue I'm actually having is, Rocket::mount panics if you try to pass it any characters that aren't Unicode. So in actuality, I have a way of solving this problem by using the approach I showed off in the original post where I just put /häcker in the get macro instead of the mount base.
I'm sorry for my confusion here, ignore everything in the original post. What should I do with this issue now, should I close it and open a new one for the real problem or just edit?
SergioBenitez
changed the title
Routes to paths with URL-encoded chars fails to match and always results in 404
UTF-8 characters are not allowed on mount points or catch prefixes
Dec 6, 2024
Rocket Version
0.5.1
Operating System
Debian Testing (upgraded last week)
Rust Toolchain Version
rustc 1.80.1 (3f5fd8dd4 2024-08-06)
What happened?
I'm trying to use URL-encoded chars in my routes and Rocket just responds with 404. Rocket manages to compile with the following test case, but the issue is that, as you can see in the log output:
when i make the request to the exact same path as the get macro was defined as, Rocket fails to match my request to my route.
This way I've done it in the test case is a reasonable assumption to how Rocket would handle paths as according to this part of the docs, Origins should be URL-encoded.
Test Case
Log Output
Additional Context
No response
System Checks
rustc
toolchain.The text was updated successfully, but these errors were encountered: