Prevent urlencoded content foo=bar from being deserialized when serializer is set to JSON#1771
Conversation
- set serializer to JSON, and turn on canonical for a more reliable test - passing conent `foo=bar&bar=` with application/x-www-form-urlencoded - return body_parameters and expect the data returns JSON
- the body contents shouldn't look like JSON and contains an `=` - header should be set to application/x-www-form-urlencoded
foo=bar from being deserialized when serializer is set to JSONfoo=bar from being deserialized when serializer is set to JSON
|
When you set Setting an automatic serializer is good for very restricted situations in which you have an app that shouldn't receive input (or send output) in any other format. We shouldn't be fitting it to various edge-cases. However, @veryrusty is the expert on serializers. :) |
|
I will wait for a suggestion from the team! Here is my thought process: In this example, the request declared that the data is not JSON, and in this case, using url encoded header. So, I am thinking Dancer2::Core::JSON should be flexible and not try to deserialize the raw data while preserving the serialization of the return data. I also can also see something like this #1577 would work in term of having to maintain my own version of JSON that allowed the behaviour. |
This PR will allow sending requests with URL-encoded content, eg:
foo=bar, to the Dancer2 route, even when the serializer is set to JSONTest added to support this new behavior.
Resolve ##1770