leafsphp / http

📡 Leaf Http module
https://leafphp.dev/modules/http/
7 stars 9 forks source link

Leaf\Http\Request - Better compatibility with standard jquery calls #4

Closed eliasnoya closed 2 years ago

eliasnoya commented 2 years ago

when you make a classic jquery call with data = $(...).serialize() form data is html encoded, for example mail=elias@gmail.com will be encoded to elias%40gmail.com, thats normal, but when you fetch on the backend w/ requests()->get('mail') you obtain the raw value from php://input, I realized that in Request::body you merge FILES, GET, POST, INPUTS...since the input is at the end, they overwrites the posts & gets usually used in the mentioned context. In my code i change the line 197 of Request.php From : $finalData = array_merge($_GET, $_FILES, $_POST, static::input($safeData)); To : $finalData = array_merge(static::input($safeData), $_GET, $_FILES, $_POST); and solves the problem, but maybe isnt the rigth thing to do

mychidarko commented 2 years ago

Actually, you can turn this off by passing false to safe data. So you'll have something like this instead:

request()->get('mail', false);

Let me know if this solves your issue