Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

Suyash2JZ
Copy link

Fix: use UTF-8 safe substr for multibyte support in mod_articles_category
Fixes #45452

Summary of Changes

Replaced the regular substr() function with mb_substr() in mod_articles_category to ensure correct multibyte string handling for UTF-8 encoded text.

Testing Instructions

  1. Create or open a Joomla site with multibyte characters (e.g., accented or non-Latin characters) in article titles or categories.
  2. Display those articles using the "Articles - Category" module.
  3. Verify that the trimming and display of multibyte titles is now correct.

Actual result BEFORE applying this Pull Request

Multibyte characters were sometimes cut off or displayed incorrectly.

Expected result AFTER applying this Pull Request

Multibyte characters are displayed correctly and not truncated.

Link to documentations

  • No documentation changes for docs.joomla.org needed
  • No documentation changes for manual.joomla.org needed

switch ($type) {
case 'month_year':
$month_year = StringHelper::substr($item->$field, 0, 7);
$month_year = StringHelper::substr($item->$field, 0, 7,'UTF-8');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$month_year = StringHelper::substr($item->$field, 0, 7,'UTF-8');
$month_year = StringHelper::substr($item->$field, 0, 7, 'UTF-8');

Code style


default:
$year = StringHelper::substr($item->$field, 0, 4);
$year = StringHelper::substr($item->$field, 0, 4,'UTF-8');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$year = StringHelper::substr($item->$field, 0, 4,'UTF-8');
$year = StringHelper::substr($item->$field, 0, 4,'UTF-8');
Suggested change
$year = StringHelper::substr($item->$field, 0, 4,'UTF-8');
$year = StringHelper::substr($item->$field, 0, 4, 'UTF-8');

Code style

@HLeithner
Copy link
Member

This pull request has been automatically rebased to 5.4-dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[5.3.0][mod_articles_category] Trim function not working good with Chinese paragraph.

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.