Skip to content

fix(core): preserve UTF-8 system tag names - #63987

Open
HsukqiLee wants to merge 2 commits into
nextcloud:masterfrom
TsinbeiLabs:contribution-63712
Open

HsukqiLee wants to merge 2 commits into
nextcloud:masterfrom
TsinbeiLabs:contribution-63712

Conversation

@HsukqiLee

Copy link
Copy Markdown

Summary

Fix system tag name truncation when a name contains multibyte UTF-8
characters and is longer than the database column limit.

The affected code previously used byte-based substr(), which could
split a UTF-8 character and produce an invalid string. The affected
paths now use mb_strcut() with explicit UTF-8 encoding.

Fixes #63712

Tests

  • PHP 8.3.8
  • PHPUnit 11.5.56
  • SQLite
  • 64 tests, 174 assertions

Command:

php vendor-bin/phpunit/vendor/bin/phpunit --fail-on-warning --fail-on-risky --display-warnings --display-deprecations --display-phpunit-deprecations --configuration tests/phpunit-autotest.xml --group DB tests/lib/SystemTag/SystemTagManagerTest.php

AI Disclosure

I used OpenCode with the gpt-5.6-sol model to assist with repository
research and implementation. I reviewed the resulting changes and
test coverage before submitting this pull request.

@HsukqiLee
HsukqiLee requested a review from a team as a code owner September 3, 2026 08:49
@HsukqiLee
HsukqiLee requested review from icewind1991, leftybournes, salmart-dev and sorbaugh and removed request for a team September 3, 2026 08:49
Use UTF-8-aware byte truncation for system tag names so multibyte characters are not split when names are limited to 64 bytes.

Add regression coverage for creating, retrieving, and updating tags with multibyte names.

Assisted-by: OpenCode:gpt-5.6-sol
Signed-off-by: Hsukqi Lee <team@tsinbei.com>
Add regression coverage for reading and updating multibyte system tag names.

Assisted-by: OpenCode:gpt-5.6-sol
Signed-off-by: Hsukqi Lee <team@tsinbei.com>
@solracsf solracsf added this to the Nextcloud 36 milestone Sep 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)


// Length of name column is 64
$truncatedTagName = substr($tagName, 0, 64);
$truncatedTagName = mb_strcut($tagName, 0, 64, 'UTF-8');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why mb_strcut and not mb_substr?

This branch has not been deployed

No deployments
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.

[Bug]: Creating/renaming a system tag with a multibyte name >64 bytes throws 500 — byte-based substr() splits UTF-8 characters in SystemTagManager

3 participants