-
Notifications
You must be signed in to change notification settings - Fork 711
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
problems with smarty_mb_str_replace PHP >= 7.1 #549
Comments
Could you please fork https://github.com/AnrDaemon/test-001 and reproduce your issue in a branch cloned from the master? |
I'd like to add to this (after having issues with latin encoded German characters in Smarty 3.1.33).... I noticed a few more minor issues related to encoding in Smarty while digging into this:
|
I have fixed the problem with adding these lines: after |
That's almost a good solution, except for 1 problem: mb_regex_encoding() supports much less encodings than mb_internal_encoding(). See the comments below the mb_regex_encoding documentation. I'm afraid, if you want to use mb_split(), then you'll have to translate the given input into utf-8 (or whatever encoding has the widest coverage), operate on it, and then translate the result back into the expected encoding. Perhaps writing a alternative mb_trim-like function that supports an encoding parameter is better. It's a nasty problem, like treading in a code minefield. |
I think this will fix it, by replacing the last "else" block in plugins/shared.mb_str_replace.php with this:
It needs testing though.
The function should do better argument type checking b.t.w. to handle objects, nulls, etc. being passed in. |
You can use |
...until you get a search string with either { or } in it. |
Sorry, I did mean to say "quote this, don't quote that". |
Without a clear test case you can't be sure if the fix is working, or if there's no sideeffects of your fix. Or that your fix won't be accidentally dropped in a future refactoring. |
Still broken in 3.1.36 |
Hmmm, that is really sad! |
Here's the forked test case demonstrating the issue and the fix: |
I see the issue, however, the fix is not appropriate. The real problem is that
This can be fixed in two ways. One is quick and dirty. One is correct and very, very tedious. |
Good news! So there is a chance to see this issue be fixed in an upcoming release? ;-) |
I'm tinkering with the code as we speak. May be, just may be, I will have a fix. I already have a regression test case, so this should be covered. |
Thanks in advance! =) |
Another problematic point is that you can not actually rely on |
|
It seems I'm going to fix A LOT of stuff in process. >.< There's lots of PHP incompatibilities and the test suite is not configured to run on minimum advertised PHP version. |
`mb_split` will fail if `$pattern` or `$string` contains byte sequences not invalid for `mb_regex_encoding()`. Convert both strings and set regex encoding to `UTF-8` before calling mb_split. Fixes smarty-php#549
`mb_split` will fail if `$pattern` or `$string` contains byte sequences not valid for `mb_regex_encoding()`. Convert both strings and set regex encoding before calling `mb_split()` if needed. Fixes smarty-php#549
`mb_split` will fail if `$pattern` or `$string` contains byte sequences not valid for `mb_regex_encoding()`. Convert both strings and set regex encoding before calling `mb_split()` if needed. Fixes smarty-php#549
I was running into an obscure issue in the PrestaShop back-office, and nailed it down to the replace modifier. It seems it was this exact same issue, and it was resolved once I installed php7.3-mbstring. Thank you for the fix, this is gonna help a lot of people! |
`mb_split` will fail if `$pattern` or `$string` contains byte sequences not valid for `mb_regex_encoding()`. Convert both strings and set regex encoding before calling `mb_split()` if needed. Fixes smarty-php#549
`mb_split` will fail if `$pattern` or `$string` contains byte sequences not valid for `mb_regex_encoding()`. Convert both strings and set regex encoding before calling `mb_split()` if needed. Fixes smarty-php#549
This was fixed in #740. |
There ist a problem with the "replace" modifier in combination with ISO-8859-1 and PHP >= 7.1
You get an empty string back in case the string contains german umlauts (öäü).
The text was updated successfully, but these errors were encountered: