• Resolved WPBot

    (@wpbot)


    Hello,

    I have a clean install of the latest at the moment version of the plugin (6.0.3.1) and when I try to change the custom messages of the form with a text in cyrillic it gets converted to UTF entities…

    For example instead of the desired success message a user sees something like this u041au0438u0440u0438u043bu0438u0446u0430.

    I’ve looked in the database and it turns out that the text is stored that way upon form update. It currently looks like this:
    {"success":"\u041a\u0438\u0440\u0438\u043b\u0438\u0446\u0430".

    The weirdest part is that all the other fields have no problems with the cyrillic symbols – for example the form description field looks just fine both in phpmyadmin and the site.

    https://wordpress.org/plugins/yikes-inc-easy-mailchimp-extender/

Viewing 15 replies - 1 through 15 (of 20 total)
  • Plugin Author Evan Herman

    (@eherman24)

    What is the message that you are trying to display?

    Thread Starter WPBot

    (@wpbot)

    It doesn’t matter – anything written in cyrillic will trigger the error – for example Кирилица.

    It shows fine in the messages editor in the form options even after the form has been saved but it doesn’t work on the frontend.

    You can easily reproduce the problem by adding this text to the success message and the form description, and compare their contents in the DB after that.

    Plugin Author Evan Herman

    (@eherman24)

    Sorry I don’t speak Russian natively (or any cyrillic language) so coming up with a Russian sentence off the top of my head is not something that can be easily achieved.

    I will have a look into the issue.

    Thank you.

    Plugin Author Evan Herman

    (@eherman24)

    So after entering some random string of Russian text, I am not able to reproduce the issue.

    Success messages display as intended. Here is a screenshot:
    https://cldup.com/erH3YVrwqP.png

    And here it is on the backend:
    https://cldup.com/P6rAS1gy9F.png

    So I’m not sure why you’re having issues on your end as it seems to be working as intended on mine.

    Thanks you.
    Evan

    Thread Starter WPBot

    (@wpbot)

    That’s weird.
    I thought the problem might be in json_encode but it could be something server related.

    Could you take a look at the contents of the error_messages DB field for that form?

    Thread Starter WPBot

    (@wpbot)

    In class-yikes-inc-easy-mailchimp-extender-admin.php on line 4937 I’ve added
    , JSON_UNESCAPED_UNICODE
    This is the block that starts from line 4925 with
    $error_settings = json_encode(
    and that fixed things both in DB and the frontend.

    The problem is that I’m not sure whether this “fix” is flawed somehow and won’t have any unforeseen side effects.
    And another problem is that I’ll have to re-apply it every time you release a new version of the plugin…

    Plugin Author Evan Herman

    (@eherman24)

    Hi,

    The only I can foresee is that JSON_UNESCAPED_UNICODE was added to php v5.4. Many of our users (and WordPress users in fact) are still on legacy versions of php. If we were to implement such a fix, many of our users would encounter a ton of errors.

    What version of MySQL is your host running? I can’t think of any reason the issue you mention would occur other than stripslashes removing the escaped values.

    Evan

    Thread Starter WPBot

    (@wpbot)

    It’s a shared hosting with the following versions (taken from cPanel):

    Apache Version 2.2.29
    PHP Version 5.4.37
    MySQL Version 5.5.45-37.4-log

    Maybe there is some setting in php.ini that is responsible for the stripslashes thing you mentioned?

    Thread Starter WPBot

    (@wpbot)

    So, I’ve tested the plugin on a few more blank WP installs (4.3.1) on different hosts (both shared and VPS) and I had the same problem with all of them.

    I’ve used PHP versions from 5.3 to 5.6 but couldn’t make it work on any of them (even with numerous changes to php.ini).

    I’ve also changed the database collation to different encodings and still nothing…

    I started reading about stripslashes and this lead me to the get_magic_quotes_gpc function… so in public/partials/shortcodes/process/process_form_submission_ajax.php I changed line 27 from

    $error_messages = json_decode( stripslashes( $form_data['error_messages'] ), true );

    to:

    if (get_magic_quotes_gpc()) {
         $err_messages = stripslashes( $form_data['error_messages'] );
    }
    else {
          $err_messages = $form_data['error_messages'] ;
    }
    $error_messages = json_decode( $err_messages, true );

    and the problem was gone (that was done on a new plugin install without the JSON_UNESCAPED_UNICODE change I talked about earlier)…

    This solution should work on all PHP versions, so could you include it in the next version if you don’t think there will be any side effects or maybe figure out something else because I really like the plugin, but losing the changes on every update doesn’t sound very appealing.

    btw, while testing the different php.ini options I found out that on PHP 5.3 the plugin doesn’t work (or at least the form editor) with

    magic_quotes_gpc = Off
    magic_quotes_runtime = Off

    I suppose you already know about that (or it might even be written somewhere in the plugin requirements that magic quotes should be turned off) but I thought to mention it just in case.

    Plugin Author Evan Herman

    (@eherman24)

    Hi WPBot,

    Thanks for looking into this in such detail. I am going to take a much closer look into this issue today and see what’s going on. I was able to reproduce it on one of my installs, but not on any of the others. I’m not entirely sure what the difference between the two installs is, but I’d like to get to the bottom of it as many of our users are international.

    I will report back here in a bit with some findings!

    Evan

    Plugin Author Evan Herman

    (@eherman24)

    I think we are going to be pushing out a patch with this fix in place. The line that you mention will be swapped out for the following:

    $error_messages = ( get_magic_quotes_gpc() ) ? json_decode( stripslashes( $form_data['error_messages'] ), true ) : json_decode( $form_data['error_messages'], true );

    I would just like to do a little testing before making anything final.

    Thanks,
    Evan

    Plugin Author Evan Herman

    (@eherman24)

    Hi,

    I had plans on getting this out today but it doesn’t look like I’ll have the time to. I’ve gotten side tracked with some client work.

    Hopefully I can find some time to get this fix out in the upcoming days.

    Sorry about that,
    Evan

    Thread Starter WPBot

    (@wpbot)

    Hi,

    No worries – I can wait a few more days or just apply it myself until the new version comes out.

    Thanks for the help and the great plugin – it’s exactly what I needed.

    Plugin Contributor yikesinc

    (@yikesinc)

    Awesome and thank you for the nice review 🙂

    Hello, I have the same problem with Czech language characters. They look weird in the messages on the web as can be seen on this picture (underlined by green): <img src=”http://imgup.cz/images/2015/11/09/login.png”&gt;

    Also on this picture there are two other issues I cannot solve (I am not a codie):

    – English text on the bottom of the box (automatically added) marked by a green box. I have not found this text in language files for the plugin so I do not know how to change it.

    – text on the red button is shifted down and I did not found how to center it vertically (I tried using span tags but it did not work).

    Can you help? Thanks!

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Custom Messages do not Support Cyrillic Characters’ is closed to new replies.