You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PlainTextErrorRenderer in Slim Framework applies HTML entity encoding to exception messages via the htmlentities function. This behavior leads to the encoding of special characters in log messages and other plain text outputs, which might not be desired in all contexts.
Slim Framework Version
4
Steps to Reproduce
Use the PlainTextErrorRenderer to handle exceptions.
Trigger an exception with a message that includes characters that are typically encoded by htmlentities (like double quotes).
Observe the output (in logs, terminal, etc.) and notice that characters are HTML entity encoded (e.g., double quotes are converted to ").
Expected Behavior
In a plain text context, one would expect the error message to be rendered as-is, without HTML entity encoding. The use of htmlentities might be more appropriate for HTML-specific renderers.
Actual Behavior
The error message is HTML entity encoded, leading to representations like " in place of double quotes in plain text outputs.
Possible Solution
Consider removing the htmlentities call from the PlainTextErrorRenderer, or provide an option to disable HTML entity encoding based on the context in which the renderer is used.
Context
This encoding issue affects logging, CLI outputs, and other scenarios where HTML entity encoding is not desirable in error messages.
The PlainTextErrorRenderer should not encode exception messages as
that's not required for plain text in the same way that it is not
required for the JsonErrorRenderer.
Closesslimphp#3298
Description
The
PlainTextErrorRenderer
in Slim Framework applies HTML entity encoding to exception messages via thehtmlentities
function. This behavior leads to the encoding of special characters in log messages and other plain text outputs, which might not be desired in all contexts.Slim Framework Version
4
Steps to Reproduce
PlainTextErrorRenderer
to handle exceptions.htmlentities
(like double quotes)."
).Expected Behavior
In a plain text context, one would expect the error message to be rendered as-is, without HTML entity encoding. The use of
htmlentities
might be more appropriate for HTML-specific renderers.Actual Behavior
The error message is HTML entity encoded, leading to representations like
"
in place of double quotes in plain text outputs.Possible Solution
Consider removing the
htmlentities
call from thePlainTextErrorRenderer
, or provide an option to disable HTML entity encoding based on the context in which the renderer is used.Context
This encoding issue affects logging, CLI outputs, and other scenarios where HTML entity encoding is not desirable in error messages.
Slim/Slim/Error/Renderers/PlainTextErrorRenderer.php
Line 49 in fdb6d61
The text was updated successfully, but these errors were encountered: