Fixed ' (and other HTML5 entities) in title for auto-link URL

Xon

Well-known member
The ' HTML5 entity in the og:title meta tag are not being decode when a URL is automatically wrapped.

For example: http://www.latimes.com/opinion/op-ed/la-oe-hemenway-guns-20150423-story.html
Gets wrapped as: There's scientific consensus on guns -- and the NRA won't like it

This is the line triggering it:
Code:
<meta property="og:title" content="There&apos;s scientific consensus on guns -- and the NRA won&apos;t like it" data-meta-updatable/>

It looks like html_entity_decode needs to some flags to handle HTML5 explicitly rather than just HTML4. However, this was added in php 5.4 so some backwards compatibility care would need to be done.
 
Just switched it to use HTML5 decoding if possible:
Code:
if (defined('ENT_HTML5'))
{
    $title = html_entity_decode($title, ENT_QUOTES | ENT_HTML5, 'UTF-8');
}
else
{
    $title = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
}
Seems to sort it and should be compatible with older versions (though the entities won't be decoded, as now).

Thanks. :)
 
Top Bottom