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
Use mbstring proxy methods #12104
Conversation
core/Common.php
Outdated
return mb_strtoupper($string, 'UTF-8'); | ||
} | ||
|
||
return strtoupper($string); |
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…vent possible unicode problems
👍 |
fixes #12101