Skip to content

Magento Framework Escaper - Critical log with special symbols #13269

Closed
@ihor-sviziev

Description

@ihor-sviziev

Preconditions

  1. Magento 2.3.3

Steps to reproduce

Case 1

  1. Register a new customer from frontend;
  2. Created one order from frontend;
  3. Add & to store view name
  • Go to Admin >> Stores >> All Stores
  • Click on "Default Store View"
  • Change Name field to "Default & Store View"
  • Click "Save Store View" button
  1. Remove all log files from magento2/var/log directory (in order to have only needed logs)
  2. Go to Frontend >> [user name] >> My Account >> My Orders;
  3. Click on "View Order" link for our order that was created in step 2;
  4. See magento2/var/log directory;

Expected result

  1. No exception logs should be there

Actual result

  1. exception.log file appeared with one line:
[[2019-12-03 10:47:42] main.CRITICAL: DOMDocument::loadHTML(): Tag date invalid in Entity, line: 1 {"exception":"[object] (InvalidArgumentException(code: 2): DOMDocument::loadHTML(): Tag date invalid in Entity, line: 1 at /home/arthur/sites/magento/magento233/vendor/magento/framework/Escaper.php:89)"} []

Case 2

  1. Register a new customer from frontend;
  2. Created one order from frontend;
  3. Go to Admin->Sales->Orders;
  4. Click on the "View" link for our order that was created in step 2;
  5. In "Order Total" block add comment "&";
  6. Click on the "Submit Comment" button;
  7. Remove all log files from magento2/var/log directory (in order to have only needed logs)
  8. Go to Frontend >> [user name] >> My Account >> My Orders;
  9. Click on "View Order" link for our order that was created in step 2;
  10. See magento2/var/log directory;

Expected result

  1. No exception logs should be there

Actual result

  1. exception.log file appeared with one line:
[[2019-12-03 10:55:22] main.CRITICAL: DOMDocument::loadHTML(): Tag date invalid in Entity, line: 1 {"exception":"[object] (InvalidArgumentException(code: 2): DOMDocument::loadHTML(): Tag date invalid in Entity, line: 1 at /home/arthur/sites/magento/magento233/vendor/magento/framework/Escaper.php:89)"} []

Reason: On View order page in the admin we have "Purchased From" block.
image

This block uses \Magento\Framework\Escaper::escapeHtml with string that contains ampersand and allowed tags is "br". In this case it writes critical log. This issue appeared in Magento 2.2.0, it was introduced in 59c2c9e + df261e7 + 624ee86.

For someone who will fix this issue:
I prepared tests for this fix in my branch that are currently fails (not only this case):
2.2-develop...ihor-sviziev:escaper-critical-log-when-ampersand-is-present

Metadata

Metadata

Assignees

Labels

Component: Framework/EscaperFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasegood first issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions