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


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

For example:
Gets wrapped as: There's scientific consensus on guns -- and the NRA won't like it

This is the line triggering it:
<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.


XenForo developer
Staff member
Just switched it to use HTML5 decoding if possible:
if (defined('ENT_HTML5'))
    $title = html_entity_decode($title, ENT_QUOTES | ENT_HTML5, 'UTF-8');
    $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. :)