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

Fix possible error when generating PDF reports containing multibyte chars #18664

Merged
merged 3 commits into from Jan 26, 2022

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Jan 20, 2022

Description:

When generating the tables for PDF reports we are truncating the row values after a certain amount of chars (55). If a string contained a multibyte character (umlauts, emojis, ...) around this position, it happened, that the multibyte sequence was disrupted.

This did cause any bigger issues on PHP 7, where only parts of the string were displayed in the PDF
On PHP 8 this produced an error, causing an abort of the PDF generation.

Simply using mb_substr instead of substr fixes this issue for me.

If someone wants to reproduce:

  • Track any type of content (action, site search keyword, ...) with something like öööööööööööööööööööööööööööööööööööööööööööööööööööööööööööö
  • Create a PDF report that contains this content type
  • Click the download button to directly generate the report

@tsteur I've targeted next_release as it's really a minimal, low-risk change

fixes #18499

Review

@sgiehl sgiehl added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Jan 20, 2022
@sgiehl sgiehl added this to the 4.7.0 milestone Jan 20, 2022
@sgiehl sgiehl requested a review from bx80 January 21, 2022 15:42
Copy link
Contributor

@bx80 bx80 left a comment

Choose a reason for hiding this comment

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

Looks good to me. I did some tests with multibyte characters in campaign names and page urls. On 4.x-dev PDF reports they are either truncated or missing altogether, with this fix they are shown correctly.

@sgiehl
Copy link
Member Author

sgiehl commented Jan 26, 2022

@tsteur feel free to merge this one if it should be included in 4.7. Otherwise I can also rebase to 4.x-dev instead.

@tsteur tsteur merged commit c4f5733 into next_release Jan 26, 2022
@tsteur tsteur deleted the m-18499 branch January 26, 2022 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants