Magento2: Opengraphs og:description contains html tags

Created on 27 Sep 2016  路  9Comments  路  Source: magento/magento2

Preconditions

  1. CE 2.1.1

    Steps to reproduce

  2. set short_description for product x to
    <ul><li>foo</li><li>bar</li></ul>

  3. view html source of product page and look out for og:description

    Expected result

  4. <meta property="og:description" content="foobar">

    Actual result

  5. <meta property="og:description" content="&lt;ul&gt;&lt;li&gt;foo&lt;/li&gt;&lt;li&gt;bar&lt;/li&gt;&lt;/ul&gt;">

$block->stripTags() is missing in vendor\magento\module-catalog\view\frontend\templates\product\view\opengraph\general.phtml

Frontend Ready for Work bug report

Most helpful comment

yes, to have " within your description text encoded properly

All 9 comments

@heldchen Thanks for reporting. Issue MAGETWO-59826

I confirm that this issue is still happening in Magento CE 2.1.5

As a workaround, would the new code be?:
<meta property="og:description" content="<?php echo $block->escapeHtml($block->stripTags($block->getProduct()->getShortDescription())); ?>" />

Would we need to leave escapeHtml in?

Thanks.

yes, to have " within your description text encoded properly

This issue was fixed for develop branch.
Closed.

Hi @veloraven,
Are there any plans to backport this fix?

I've applied the fix described here but I'm still getting html tags when I share products on Facebook. I'm using 2.1.6

Sorry for my post. Changing file as it is described here: https://github.com/magento/magento2/issues/6776
fixed my issue.
Thanks,
Gabriela

Hello, I've applied the fix in general.phtml but after a while, when I added a new product I was getting an exception on product pages. I had to delete the file to have products displaying again. So, I think you should have to keep this issue opened.

Was this page helpful?
0 / 5 - 0 ratings