Magento2: escapeHtml not working for tags with attributes

Created on 12 Apr 2017  路  3Comments  路  Source: magento/magento2

Preconditions


  1. Magento Enterprise 2.1.4
  2. PHP 7.0.13

Steps to reproduce

  1. Add the following to any template file. Works e.g. in logo.phtml.
    <?php echo $block->escapeHtml('<a href="#">standard link</a>', ['a']); ?>
    compare output with
    <?php echo $block->escapeHtml('<a>standard link</a>', ['a']); ?>
  2. Replicates with other tags e.g. <p> vs <p class=''>

Expected result

  1. Tag escaping works regardless of tag attributes and not only for very simple tags such as <br/>
    HTML: <a href="#">standard link</a> <a>standard link</a>

    Actual result

wth
HTML: &lt;a href="#"&gt;standard link <a>standard link</a>

Cannot Reproduce Clear Description Format is valid bug report

All 3 comments

Experiencing same issue with CE 2.1.4. For my issue, I had to change the code
FROM:
TO:

Note the data-bind type.

This issue is resolved in updated version of magento 2.2 CE not sure in Enterprise version.

@magentomaniac, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.1.9

Was this page helpful?
0 / 5 - 0 ratings