Skip to content

contradictory when using escapeHtml after getFormattedOption #24349

@dbsdsun

Description

@dbsdsun

Preconditions (*)

1.Magento 2.3.2

Steps to reproduce (*)

1.in vendor\magento\module-sales\view\adminhtml\templates\items\column\name.phtml line 33

<?php $_option = $block->getFormattedOption($_option['value']); ?>
<?php $dots = 'dots' . uniqid(); ?>
<?= $block->escapeHtml($_option['value']) ?>
  1. the class of $block is vendor\magento\module-sales\Block\Adminhtml\Items\Column\Name.php

    public function getFormattedOption($value)
    {
    $remainder = '';
    $this->truncateString($value, 55, '', $remainder);
    $result = [
    'value' => nl2br($this->truncateResult->getValue()),
    'remainder' => nl2br($this->truncateResult->getRemainder())
    ];
    return $result;
    }

  2. problem:
    in name.phtml, "
    " may be added in getFormattedOption, then "
    " is escaped by
    $block->escapeHtml

Expected result (*)

  1. maybe, you can call with parameter $allowedTags like this

    escapeHtml($_option['value'], ['br']) ?>
  2. Actually, this issue exists in many template files.

Actual result (*)

Lens Options: Single Vision Distance (SVD);<br /> Index: 1.5;<br /> Seg Heigh t: 50;<br /> Right DPD: 40;<br /> Left DPD: 40.

Metadata

Metadata

Assignees

Labels

Component: Framework/CodeFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: 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