icarus-consulting / Yaapii.Http

C# Library for Http Request
MIT License
7 stars 0 forks source link

FormParams tolerates special characters #78

Closed DFU398 closed 3 years ago

DFU398 commented 3 years ago

Expected Behavior

If a key or value stored in the body as form params contains special characters, they are escaped, encoded or something else to make that data compatible with content type application/x-www-form-urlencoded.

Actual Behavior

Characters like '&', '+', or '=' may cause unexpected behavior or errors.

Mention any other details that might be useful

The problem is in AspNetCoreWire:


                body =
                    new BytesOf(
                        new Yaapii.Atoms.Text.Joined("&",
                            new MappedDictionary<string>((key, value) =>
                                $"{key}={value()}",
                                formParams
                            )
                        )
                    );

There has to be a better way of doing this. Using System.Net.Http.FormUrlEncodedContent instead of System.Net.Http.ByteArrayContentmay solve this.

Steps to reproduce the behavior

The log given by the failure.