Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JHtmlString::truncateComplex not working with some strings #28822

Open
sba opened this issue Apr 27, 2020 · 6 comments
Open

JHtmlString::truncateComplex not working with some strings #28822

sba opened this issue Apr 27, 2020 · 6 comments

Comments

@sba
Copy link
Contributor

sba commented Apr 27, 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

@ReLater
Copy link
Contributor

ReLater commented Apr 27, 2020

Confirmed with 3.9.19-dev.

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

@sba
Copy link
Contributor Author

sba commented Apr 27, 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.

@N6REJ
Copy link
Contributor

N6REJ commented Apr 27, 2020

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

@mbabker
Copy link
Contributor

mbabker commented Apr 27, 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.

@ReLater
Copy link
Contributor

ReLater commented Apr 27, 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.

@chmst
Copy link
Contributor

chmst commented Apr 27, 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.

@Hackwar Hackwar added the bug label Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants