I've added meta tags to a template override to have OG-metatags for Facebook and Twitter in the rendered page of an (K2) article. For safety reasons it is advised to escape the title tag. So my code is:
$document->addCustomTag('<meta property="og:title" content="'.$this->escape($this->item->title).'">');
This will create a tag that looks like this, where the title of the page is
Ugenda's festivaloverzicht :
<meta property="og:title" content="Ugenda&#039;s festivaloverzicht">
See an example here:
www.ugenda.nl/agenda/festivals
Note that the title has the wrong encoding for the apostrophe. It should be
' or
'.
So Facebook doesn't recognize the titel correctly and it shows the encoding instead of the apostrophe. (See:
www.facebook.com/Ugenda/posts/10156534292767719
)
Am I escaping the item->title falsely? Or is there no need to escape it? (And what about security?)
Note that in pages in the eventlist part of our site, the og-tag is rendered correctly. See for example:
www.ugenda.nl/agenda/event/102529-battlefield-fietstour-de-bevrijding-van-nijmegen
where the tag is:
<meta property="og:title" content="Battlefield Fietstour 'De bevrijding van Nijmegen'">
and the code:
$document->addCustomTag('<meta property="og:title" content="'.$this->escape($this->item->title).'">');