Skip to content

HTML Escaper Issue #37693

@Nuranto

Description

@Nuranto

Preconditions and environment

  • Magento version 2.4.6-p1

Steps to reproduce

  1. Edit a theme template (header.phtml for instance)
  2. Add this line somewhere : <?= $escaper->escapeHtml('Speed < 10m/s', ['b']); ?>

Expected result

Displays Speed < 10m/s

Actual result

Displays Speed.

Generates exception :

main.CRITICAL: InvalidArgumentException: DOMDocument::loadHTML(): htmlParseStartTag: invalid element name in Entity, line: 1 in /var/www/html/vendor/magento/framework/Escaper.php:96
Stack trace:
#0 [internal function]: Magento\Framework\Escaper->Magento\Framework\{closure}(2, 'DOMDocument::lo...', '/var/www/html/v...', 108)
#1 /var/www/html/vendor/magento/framework/Escaper.php(108): DOMDocument->loadHTML('<html><body id=...')
#2 /var/www/html/app/design/frontend/Namespace/theme/Magento_Theme/templates/html/header.phtml(69): Magento\Framework\Escaper->escapeHtml('Speed < 10m/s', Array)
#3 /var/www/html/vendor/magento/framework/View/TemplateEngine/Php.php(71): include('/var/www/html/a...')

Additional information

It only fails when there is html tags exception : <?= $escaper->escapeHtml('Speed < 10m/s'); ?> works correctly.

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: UI FrameworkComponent: Framework/EscaperIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Progress: ready for devReported on 2.4.6-p1Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions