-
-
Notifications
You must be signed in to change notification settings - Fork 413
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
[🐛 BUG]: RoadRunner alters form body #1696
Comments
Hey @revenkroz 👋🏻
I'm not quite sure that I understand the problem. What kind of changes do you mean? Order of the args? |
I mean the contents of some form fields in the request are different from what ends up in the application. For example field |
@revenkroz I mean, what is different? How did you check this? Have you tried saving and comparing files? |
@rustatian Yeah, I've tried sending and saving files. As you can see in repo I mentioned above, when you send file to an app running with RR and save it, the file becomes corrupted. If you run a default PHP server (e.g. |
@revenkroz I'm a little suspicious of that line: parse_str((string)$request->getBody(), $decodedBody); RR sends byte-encoded data and casting it to string type might be wrong. Are you getting the same result with P.S.: I'll check this tomorrow, I'm working on the other feature, and can't check your code right now 😭 |
@rustatian yeah, the same thing with |
@revenkroz Oh, I missed that. Are you trying to send a file with |
@rustatian True. It should be another Content-Type or should be encoded in base64 at least. But we have an old client package for this service that sends in |
@revenkroz You actually getting the raw body 😃 (if you use the The second part is parsed body. Your attached PNG contains a lot of symbols that should be Sample of the escaped output:
|
@rustatian my bad, mistyped :) I updated the example. In case of I tried to fix all of this by writing my own body parser for RR app, but it is not working in all my tests. |
Could you please save the data you receive inside the RR (with and without raw) and attach these files to your repository? |
@rustatian here: https://github.com/revenkroz/rr-urlencoded-bug/tree/main/results I updated the code to save data from request. Now when testing, you only need to change |
Uh, yeah, I think that's because we're sending the JSON from RR to the PHP worker. We're moving to the PROTO protocol, so we won't have these weird content issues like PNG files. |
@revenkroz Or you can try |
@rustatian Sounds great! I will test it after the move from json. Yeah, we have a problem with our legacy codebase - I think we should try to use another methods (multipart or base64), but update will be hard :) Thanks for help anyway! |
@revenkroz I'll leave this bug open, when I implement RAW proto payloads, I'll ping you here 😃 |
@rustatian I'm unsure if this is the direct cause of Author's problem but in This is incorrect as it breaks value escaping done by the browser (when the user inserts & [ ] = in a field) and will prevent accurate usage of This is hitting us particularly hard as we are trying to work around #1634 by parsing urlencoded bodies manually but are unable to do so since the raw body is also corrupted. |
Hey @Starfox64 👋 |
Hey everyone, we tested this scenario with the new proto encoder, everything works good. You'll need to use |
@rustatian Hi! I compiled RR with
|
Hey @revenkroz 👋 |
@rustatian can confirm, it works! With installed |
Cool 👍 |
BTW: do not forget to install the |
Hi, the package |
No duplicates 🥲.
What happened?
There is one somewhat old service and a client to it. Files are sent there wrapped in
application/x-www-form-urlencoded
. When this service was migrated to RoadRunner, it was discovered that some of the files were corrupted.We tried to fix it with
raw_body: true
option and parse the request ourselves, but the problem persists. Something inside RoadRunner is changing the contents of the request.Version (rr --version)
2023.2.2
How to reproduce the issue?
I did a quick test with RR and default PHP server. The last one saves files properly, RR doesn't.
Repo has a
test.png
file for test - this file is sent to the server and saved under a new name so you can check what's going on.https://github.com/revenkroz/rr-urlencoded-bug
Relevant log output
No response
The text was updated successfully, but these errors were encountered: