xbTruncString Plugin
Intro Page

The xbTruncString plugin is a system plugin to override the default JHtml::_('string.truncate') function.

For JHtml helper (and other helper) functions, as long as they aren't called directly (eg by using JHtmlString::truncate() ) it is possible to register a custom handler for the function which will override the default in the library.

Helper functions should always be called using the format JHtml::_('string.truncate',...). So long as this format is used then the xbTruncString plugin will override the function with its own bug-fixed version.

It does this by registering a custom handler for the target function name ('string.truncate') using a listener in its onAfterInitialise() function.

I am indebted to Michael Babker for showing me how to do this in his code example at https://github.com/mbabker/bs3-demo/blob/master/plg_system_bootstrap3/bootstrap3.php which I have adapted to wrap the bug-fixed truncate() function.

Install the plugin in the usual way and don't forget to enable it. It works with Joomla 3.9 and probably most of the 3.x series. (the truncate bugs have existed since at least J2.5). It uses the update system, although I hope there won't be any updates!