-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MC-23553: Invalid Template Strings when Translate Inline enabled #32002
Conversation
Hi @mastiuhin-olexandr. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
if ($translateInline->isAllowed()) { | ||
return $this->inlineSensitiveEscapeHthmlAttr((string) $string); | ||
} | ||
|
||
return $this->getEscaper() | ||
->escapeHtmlAttr((string) $string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ternary operator to avoid too much early returns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you, please, confirm that it will look better?
if ($translateInline->isAllowed()) { | |
return $this->inlineSensitiveEscapeHthmlAttr((string) $string); | |
} | |
return $this->getEscaper() | |
->escapeHtmlAttr((string) $string); | |
return $translateInline->isAllowed() ? | |
$this->inlineSensitiveEscapeHthmlAttr($string) : | |
$this->getEscaper() | |
->escapeHtmlAttr($string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, like this:
if ($translateInline->isAllowed()) { | |
return $this->inlineSensitiveEscapeHthmlAttr((string) $string); | |
} | |
return $this->getEscaper() | |
->escapeHtmlAttr((string) $string); | |
$translateInline = $this->getTranslateInline(); | |
return $translateInline->isAllowed() | |
? $this->inlineSensitiveEscapeHthmlAttr((string) $string) | |
: $this->getEscaper()->escapeHtmlAttr((string) $string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
*/ | ||
private function inlineSensitiveEscapeHthmlAttr(string $text): string | ||
{ | ||
$escaper = $this->getEscaper(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check that string has length more or eq 6 before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, fixed.
* @return void | ||
* @dataProvider escapeHtmlAttrWithInlineProvider | ||
*/ | ||
public function testEscapeHtmlAttrWithInline(string $input, string $output): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please dont contract words. Rename
testEscapeHtmlAttributeWithInlineTranslateEnabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
* | ||
* @return array | ||
*/ | ||
public function escapeHtmlAttrWithInlineProvider(): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please dont contract words. Rename
escapeHtmlAttributeWithInlineTranslateEnabledDataProvider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@magento run all tests |
1 similar comment
@magento run all tests |
@magento import code to https://github.com/magento-tsg/magento2ce |
@zakdma, an error occurred during the Pull Request import. |
@zakdma the branch with code successfully imported into |
Hi @mastiuhin-olexandr, thank you for your contribution! |
@@ -3,6 +3,7 @@ | |||
* Copyright © Magento, Inc. All rights reserved. | |||
* See COPYING.txt for license details. | |||
*/ | |||
declare(strict_types=1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug P2
Description (*)
This is a usability issue.
Fixed Issues (if relevant)
Manual testing scenarios (*)
Preconditions:
Expected: Text remains the same
Actual: Text shows formatting characters like {{ }}
Contribution checklist (*)