Special characters in message break XML/JSON representation
ilovemistakes opened this issue · comments
Алексей Чупров commented
Special characters (double quotes, backslashes, etc.) are not escaped when Json or Xml formatter formats the message:
return \sprintf(
'{"error":{"id":"%s","message":"%s"}}',
$exception->getIdentifier(),
$exception->getMessage()
);
So something like new Exception('Double "quotes" here')
produces unparsable json:
{"error":{"id":"qK7Mm88nSznmGu5kawSEtT","message":"Double "quotes" here"}}
Straightforward fix is to use json_encode()
and htmlspecialchars()
in json and xml formatters respectively.
Julián Gutiérrez commented
Thanks for the issue, I've push a commit to fix it