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

Use mbstring proxy methods #12104

Merged
merged 2 commits into from Sep 25, 2017
Merged

Use mbstring proxy methods #12104

merged 2 commits into from Sep 25, 2017

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Sep 22, 2017

fixes #12101

@sgiehl sgiehl added 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. labels Sep 22, 2017
core/Common.php Outdated
return mb_strtoupper($string, 'UTF-8');
}

return strtoupper($string);
Copy link
Member

Choose a reason for hiding this comment

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

here we should default to returning the original string, otherwise we risk destroying the unicode string when mbstring becomes un-available for some reason. Better keep original string than risking breaking it 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

We aren't doing that in the method above for strtolower as well

Copy link
Member

Choose a reason for hiding this comment

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

let's do it in all mb_ proxy methods to avoid destroying unicode strings

Copy link
Member Author

Choose a reason for hiding this comment

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

Imho we shouldn't take care of that. As we can't avoid problems with unicode. substr for example might cut off within a multibyte char, strlen might return an incorrect length.
Also Twig for example does the same in some of their filters: if mb_strtolower isn't available they use strtolower

Copy link
Member

Choose a reason for hiding this comment

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

As we can't avoid problems with unicode.

Actually we can avoid potential problems by not touching the string... ideally we would detect when it's a unicode string but this may get tricky (or slow)

Copy link
Member Author

Choose a reason for hiding this comment

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

Well ok, if you think it makes sense to change that now after it was already over 6 years in the code and we didn't get any bug report about it...

Copy link
Member

Choose a reason for hiding this comment

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

I think what @sgiehl was pointing out we might avoid it the problem there but get the problem somewhere else... not quite getting the problem as well @mattab ?

@mattab mattab merged commit 9c89808 into 3.x-dev Sep 25, 2017
@mattab
Copy link
Member

mattab commented Sep 25, 2017

👍
(It's a very unlikely bug indeed (especially since we now require mbstring) but i wouldn't be surprised some users would have experienced it and maybe not report it... )

@mattab mattab deleted the mbstring branch September 25, 2017 22:29
@mattab mattab added this to the 3.1.2 milestone Sep 25, 2017
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
3 participants