Skip to content

Commit 4e3917c

Browse files
committed
Merge branch '5.4' into 6.4
* 5.4: - Respond to "patches welcome" comment
2 parents 0b650cb + 5961ea1 commit 4e3917c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

components/http_foundation.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,16 @@ The ``JsonResponse`` class sets the ``Content-Type`` header to
944944
Only methods that respond to GET requests are vulnerable to XSSI 'JSON Hijacking'.
945945
Methods responding to POST requests only remain unaffected.
946946

947+
.. warning::
948+
949+
The ``JsonResponse`` constructor exhibits non-standard JSON encoding behavior
950+
and will treat ``null`` as an empty object if passed as a constructor argument,
951+
despite null being a `valid JSON top-level value`_.
952+
953+
This behavior cannot be changed without backwards-compatibility concerns, but
954+
it's possible to call ``setData`` and pass the value there to opt-out of the
955+
behavior.
956+
947957
JSONP Callback
948958
~~~~~~~~~~~~~~
949959

@@ -1036,6 +1046,7 @@ Learn More
10361046
.. _nginx: https://www.nginx.com/resources/wiki/start/topics/examples/xsendfile/
10371047
.. _Apache: https://tn123.org/mod_xsendfile/
10381048
.. _`JSON Hijacking`: https://haacked.com/archive/2009/06/25/json-hijacking.aspx/
1049+
.. _`valid JSON top-level value`: https://www.json.org/json-en.html
10391050
.. _OWASP guidelines: https://cheatsheetseries.owasp.org/cheatsheets/AJAX_Security_Cheat_Sheet.html#always-return-json-with-an-object-on-the-outside
10401051
.. _RFC 8674: https://tools.ietf.org/html/rfc8674
10411052
.. _Doctrine Batch processing: https://www.doctrine-project.org/projects/doctrine-orm/en/2.14/reference/batch-processing.html#iterating-results

0 commit comments

Comments
 (0)