-
-
Notifications
You must be signed in to change notification settings - Fork 542
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
Troubles with cyrillic label #218
Comments
This one is extremely similar to Issue #210, i.e. it is due to inproper handling of the UTF-8 strings causing json_encode to choke on the illegal UTF-8 sequence and bail out returning empty JSON array to the AJAX frontend instead of meaningfull data. I've hit this one with a Description field being populated with a long enough cyrillic string. In server logs one could notice a warning:
The cause is on the line 1892 of items.queries.php: ...
$html .= ' <font size=2px>[' . strip_tags( stripslashes( substr( CleanString( $reccord['description'] ), 0, 30) ) ) . ']</font>';
... To fix it, replace this line with one of the following, depending on your PHP configuration (i.e., use mb_substr if you've got mbstring module enabled or use iconv_substr if you've got iconv module active): ...
$html .= ' <font size=2px>[' . strip_tags( stripslashes( mb_substr( CleanString( $reccord['description'] ), 0, 30, "UTF-8") ) ) . ']</font>';
... ...
$html .= ' <font size=2px>[' . strip_tags( stripslashes( iconv_substr( CleanString( $reccord['description'] ), 0, 30, "UTF-8") ) ) . ']</font>';
... |
Actually there's a bunch of other inproper uses of substr() in the items.queries.php which also should be fixed. In general I have to state that TeamPass is not safe for non-ASCII characters use it its current form. |
Alexey thank you very much. Works good with this fix. I think we can replace all substr with mb_substr in items.queries.php for more stability? |
Yep, it's what should be done at every place where PHP code deals with UTF-8 strings. Trouble is that with fresh PHP versions (5.0+) running on *nix hosts it might be better to use iconv_XX() funcs, while for Windows-based hosts and/or some *nix setups using mbstring mb_XX() funcs might be a more apropriate choice. For example, in my case mbstring module simply isn't available on the host i have TeamPass installed on (and I don't want to compile/install it as iconv serves my needs well). |
Very interesting post ... I'll try to think about a solution for that. Thank you for reporting solution and explanations ;-) |
You're welcome. |
Had this problem too, fixed in my fork, and, as fair as I can see, Nils added it to the original. Try upgrading to the latest version, it does have the fix. |
This commit: vasilykolosov@446df42 |
When used in the Cyrillic label longer than 34 characters item is not displayed.
example: Доступ к управлению услуг регистратора домена
The text was updated successfully, but these errors were encountered: