File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -902,6 +902,16 @@ The ``JsonResponse`` class sets the ``Content-Type`` header to
902
902
Only methods that respond to GET requests are vulnerable to XSSI 'JSON Hijacking'.
903
903
Methods responding to POST requests only remain unaffected.
904
904
905
+ .. warning ::
906
+
907
+ The ``JsonResponse `` constructor exhibits non-standard JSON encoding behavior
908
+ and will treat ``null `` as an empty object if passed as a constructor argument,
909
+ despite null being a `valid JSON top-level value `_.
910
+
911
+ This behavior cannot be changed without backwards-compatibility concerns, but
912
+ it's possible to call ``setData `` and pass the value there to opt-out of the
913
+ behavior.
914
+
905
915
JSONP Callback
906
916
~~~~~~~~~~~~~~
907
917
@@ -994,6 +1004,7 @@ Learn More
994
1004
.. _nginx : https://www.nginx.com/resources/wiki/start/topics/examples/xsendfile/
995
1005
.. _Apache : https://tn123.org/mod_xsendfile/
996
1006
.. _`JSON Hijacking` : https://haacked.com/archive/2009/06/25/json-hijacking.aspx/
1007
+ .. _`valid JSON top-level value` : https://www.json.org/json-en.html
997
1008
.. _OWASP guidelines : https://cheatsheetseries.owasp.org/cheatsheets/AJAX_Security_Cheat_Sheet.html#always-return-json-with-an-object-on-the-outside
998
1009
.. _RFC 8674 : https://tools.ietf.org/html/rfc8674
999
1010
.. _Doctrine Batch processing : https://www.doctrine-project.org/projects/doctrine-orm/en/2.14/reference/batch-processing.html#iterating-results
You can’t perform that action at this time.
0 commit comments