No Code Attached Yet bug
avatar sba
sba
27 Apr 2020

Steps to reproduce the issue

$text = "<b>Lorem ipsum dolor sit amet,</b><br>consectetur adipisicing elit. Animi aspernatur aut deserunt dolorum excepturi, laudantium maxime minus molestiae nihil nobis numquam, quam quasi voluptatibus. Accusamus ipsum nullase isquam eos.";
$text_truncated = JHtmlString::truncateComplex($text, 220, true);

Expected result

$text_truncated = "<b>Lorem ipsum dolor sit amet,</b><br>consectetur adipisicing elit. Animi aspernatur aut deserunt dolorum excepturi, laudantium maxime minus molestiae nihil nobis numquam, quam quasi voluptatibus. Accusamus ipsum nullase isquam...";

Actual result

$text_truncated = "";

System information (as much as possible)

PHP erstellt für | Windows NT SBA-AHW2019 10.0 build 18363 (Windows 10) AMD64
Datenbanktyp | mysql
Datenbankversion | 5.5.5-10.3.10-MariaDB
Datenbankzeichensatz | latin1_swedish_ci
Datenbankverbindungszeichensatz | utf8mb4_general_ci
PHP-Version | 7.3.6
Webserver | Apache/2.4.39 (Win64) OpenSSL/1.1.1c PHP/7.3.6
PHP-Interface für den Webserver | apache2handler
Joomla!-Version | Joomla! 3.9.18 Stable [ Amani ] 21-April-2020 19:30 GMT
Joomla!-Plattform-Version | Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT
Browsererkennung | Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0

Additional comments

avatar sba sba - open - 27 Apr 2020
avatar joomla-cms-bot joomla-cms-bot - change - 27 Apr 2020
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 27 Apr 2020
avatar sba sba - change - 27 Apr 2020
The description was changed
avatar sba sba - edited - 27 Apr 2020
avatar sba sba - change - 27 Apr 2020
The description was changed
avatar sba sba - edited - 27 Apr 2020
avatar sba sba - change - 27 Apr 2020
The description was changed
avatar sba sba - edited - 27 Apr 2020
avatar ReLater
ReLater - comment - 27 Apr 2020

Confirmed with 3.9.19-dev.

When I add a character before the starting <b> like z<b> it works.

avatar sba
sba - comment - 27 Apr 2020

it also works with additional chars at the end or when changing order of words (spaces) at the end - I tried to find and fix the bug, but its not so easy - the bug occurs only under certain circumstances.

avatar N6REJ
N6REJ - comment - 27 Apr 2020

what happens if you use $text_truncated = JHtmlString::testTruncateComplex($text, 220, true);

avatar mbabker
mbabker - comment - 27 Apr 2020

what happens if you use $text_truncated = JHtmlString::testTruncateComplex($text, 220, true);

You can't use the methods from the PHPUnit test suite in the production code.

avatar ReLater
ReLater - comment - 27 Apr 2020

<i>Lorem ipsum dolor sit amet,</i> and so on doesn't work.

<i>Lorem ipsum dolor<br>sit amet,</i> works (BR between opening and closing I).

<em>Lorem ipsum dolor sit amet,</em> works.

Looks like it has something to do with the 1-character tags.

avatar chmst
chmst - comment - 27 Apr 2020

The same with JHtml::_('string.truncateComplex', $text, 220);

It works with maximum 200 or smaller numbers, JHtml::_('string.truncateComplex', $text, 200);
but not with maximum 220, JHtml::_('string.truncateComplex', $text, 220);

Manipulating the text lenth or the maximum number gives different results. Some work fine, some don't.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28822.
avatar chmst chmst - change - 27 Apr 2020
Status New Confirmed
avatar Hackwar Hackwar - change - 20 Feb 2023
Labels Added: No Code Attached Yet bug
Removed: ?
avatar Hackwar Hackwar - labeled - 20 Feb 2023

Add a Comment

Login with GitHub to post a comment