-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Fix meta title property #11368
Fix meta title property #11368
Conversation
@@ -136,6 +136,12 @@ public function renderMetadata() | |||
protected function processMetadataContent($name, $content) | |||
{ | |||
$method = 'get' . $this->string->upperCaseWords($name, '_', ''); | |||
if($name === 'title') { | |||
if (!$content) { | |||
$content = $this->escaper->escapeHtml($this->pageConfig->$method()->get()); |
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.
Why do we need escapeHtml
here? Seems inconsistent with other meta data getters.
Maybe just add __toString
to \Magento\Framework\View\Page\Title
?
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.
Becouse in the same file at line 109 we have:
return '<title>' . $this->escaper->escapeHtml($this->pageConfig->getTitle()->get()) . '</title>' . "\n";
so i reproduced the same behaviour
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.
I think the original reason for that is that if someone enter some html inside the title
is has to be escaped to not break the html
tests are failing, i'll try to fix them |
@magento-engcom-team any news? |
Hi @slackerzz, changes looks good to me now but process has changed a bit since the time this PR was created. We need to deliver any contribution into |
Hi @orlangur, i'll create a new PR since changing the target branch generates a lot of conflicts |
Hi @slackerzz. Thank you for your contribution. |
Description
If, inside a controller you try to set metadata title with:
you will get an error on frontend:
Recoverable Error: Object of class Magento\Framework\View\Page\Title could not be converted to string...
becouse
processMetadataContent
will return an istance ofMagento\Framework\View\Page\Title
instead of a string.Fixed Issues (if relevant)
Manual testing scenarios
Scenario 1
execute
function add:Scenario 2
execute
function add:Contribution checklist