Repository navigation
Conversation
michalsn
left a comment
There was a problem hiding this comment.
This is again a good catch, but I'd stick with unset() and json_encode() here. A custom JSON scanner adds maintenance overhead and can slow processing of larger, more complex payloads. That feels like a lot to take on for fairly uncommon cases. Formatting changes like 1.10 -> 1.1 don't change the number itself.
The precision issues are real, though, so I'd document the limitation. Anyone who needs to preserve the original JSON can send the CSRF token only in the header.
Something like this should be enough for the docs:
If you include the CSRF token in a JSON object, removing it decodes and re-encodes the body. This changes its formatting and may affect number precision. To keep the JSON body unchanged, send the token in the
X-CSRF-TOKENheader and leave the CSRF field out of the body.
f34b1f7 to
f831fad
Compare
Description
Adds a note in the CSRF documentation explaining that removing the CSRF token from a JSON object decodes and re-encodes the body (which affects formatting and may impact number precision), and recommends sending the token in the
X-CSRF-TOKENheader instead if the body needs to remain intact.Checklist: