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 following code htmlspecialchars($string, ENT_XML1, "UTF-8") triggers the warning
38 | WARNING | The use of function htmlspecialchars() is discouraged; use
| | \Magento\Framework\Escaper->escapeHtml() instead
| | (Magento2.Functions.DiscouragedFunction.DiscouragedWithAlternative)
Expected behavior
The suggested alternative is not an equivalent solution. A brief search over the Magento codebase also reveals there is no mention of ENT_XML1. Also \Magento\Framework\Escaper::$htmlSpecialCharsFlag is a private property making it impossible to set ENT_XML1 in a custom implementation.
Benefits
Ensure XML content can be generated correctly with-in a Magento module.
Additional information
Solutions would be either to a.) ensure the discouraged function sniff only triggers in code that is covered by the alternative or b.) add options to escape for XML in \Magento\Framework\Escaper
The text was updated successfully, but these errors were encountered:
Hi @fooman. Thank you for your report.
To speed up processing of this issue, make sure that you provided sufficient information.
Add a comment to assign the issue: @magento I am working on this
Description
The following code
htmlspecialchars($string, ENT_XML1, "UTF-8")
triggers the warningExpected behavior
The suggested alternative is not an equivalent solution. A brief search over the Magento codebase also reveals there is no mention of
ENT_XML1
. Also\Magento\Framework\Escaper::$htmlSpecialCharsFlag
is a private property making it impossible to setENT_XML1
in a custom implementation.Benefits
Ensure XML content can be generated correctly with-in a Magento module.
Additional information
Solutions would be either to a.) ensure the discouraged function sniff only triggers in code that is covered by the alternative or b.) add options to escape for XML in
\Magento\Framework\Escaper
The text was updated successfully, but these errors were encountered: