-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong flash message when name is numeric #1263
Comments
This is a deficiency in the encoding scheme for the flash message cookie: The workaround is to start the To fix, we should change the flash message encoding. For example, adding a delimiter character to end the length field: |
Thanks a lot for the explanation. By the way, is there a cleaner way to flash a struct (ID of the form + message) with Rocket? Maybe just use JSON serialization in the message field? |
Sure! If the message you are storing is structlike, you can serialize it with something like But if you only need ID + text, you could use a dummy |
Yes it's even easier :-D Thanks for the tip! |
Hi,
I'm using Rocket v0.4.4. My code is available in https://gitlab.com/thibauddauce/youtube-rust-rocket/-/commit/ae858382ac3b85b51fa9c77d04febffe73829f43.
When I set the flash name as an integer, the flash message is split in the following request.
The result:
If the flash message is shorter like "Some text", the flash is not set.
If the name is
9
the split happen later:If the name is
10
the flash is not set:If the name is "1a" (not numeric) the split is even weirder:
I really don't understand the problem. Don't hesitate if you need me to do additional checks.
My real problem is that I have multiple forms on my page, and I want to associate an ID to my flash message to show the message near the corresponding form. I don't know how to do that in Rocket. I thought using the
name
part to store the ID but it's not working :-DThe text was updated successfully, but these errors were encountered: