• Resolved kbaldac

    (@kbaldac)


    We have been happy with your plugin for years. But for the past 1-2 months, we have had problems with our subject lines showing, in some cases, complete ‘garbage’ full of question marks and, in other cases, html codes for special chars. We’ve tried turning on UTF-8 and turning it off but can’t find a setting that works for all subjects. Even more concerning is that in our small (3-person) web team, we are getting inconsistent results. So for example, two of us get all the question marks in a topic of no special characters with UTF-8 turned on, while the other gets a good subject line with UTF-8 turned on (even if it has special chars). Any recommendations? We’re staying current with releases on our test system so we’re on 2.11 with WordPress 5.5.1.

Viewing 15 replies - 16 through 30 (of 31 total)
  • Plugin Author useStrict

    (@usestrict)

    @matoca, thanks for that information. It helps to validate my theory and try to find a good solution.

    Karen,

    So the UTF-8 code uses quoted-printable encoding by default. We can try to change that to base64 and see if that’ll work. At this stage, I’m mainly wondering if the server is acting up with any encoding scheme or just quoted-printable.

    Please add the following to your functions.php file.

    
    function my_subject_base64( $prefs )
    {
        $prefs['scheme'] = 'B';
        
        return $prefs;
    }
    add_filter( 'bbpnns_subject_enc_preferences', 'my_subject_base64', 10, 1);
    

    The downside is that extensions such as WP Email Logging will have totally unreadable subject lines.

    Please let me know if that works.

    • This reply was modified 4 years, 2 months ago by useStrict. Reason: Added instructions on where to place the code
    Thread Starter kbaldac

    (@kbaldac)

    Sorry for delay in reply
    Our system is on Krystal web site I think our domain is running on a litespeed web server running CloudLinux OS.

    Karen

    Plugin Author useStrict

    (@usestrict)

    Hi Karen,

    What about the email? Do you use the server’s email system or do you connect to an external one?

    I’m also experiencing this same issue.

    Email notifications have the Subject line:

    =?UTF-8?Q?[BuildMyBrandiD]=20New=20Forum=20topic:=20No=20hamburge?= =?UTF-8?Q?r=20menu=20for=20mobile=20site?=

    The content of the email is fine and displays correctly.

    This started about a week or two ago.

    Please help! Thanks in advance!

    Thread Starter kbaldac

    (@kbaldac)

    We use the standard Unix mail server supplied by Krystal.

    Karen

    To Alexmustin – I think you just need to set UTF encode off

    Plugin Author useStrict

    (@usestrict)

    @alexmustin, thanks for reaching out.

    Let’s try to find a common denominator.

    1. What PHP version are you using?
    2. What WordPress version are you using?
    3. Can you try to downgrade to bbpnns version 2.10 or even 2.9.5.1 and let me know if it’s still happening? You can download the older versions from https://www.ads-software.com/plugins/bbpress-notify-nospam/advanced/

    Plugin Author useStrict

    (@usestrict)

    @kbaldac, setting UTF-8 off will definitely stop the encoding issue, but it will also not convert any html entities that may be added to the title.

    Because I cannot replicate the problem, we need to find the common denominator for everyone facing this issue so I can find the root cause and fix it.

    Plugin Author useStrict

    (@usestrict)

    Here’s another test we can try (again, sorry for asking this but as I cannot replicate the issue locally, I have no other option).

    Original code:

    
    if ( true === $do_enc && function_exists( 'iconv_mime_encode' ) )
    {
        /**
         * Enable UTF-8 characters in subject line
         * @since 1.9
         */
        $filtered_subject = iconv_mime_encode( 'Subject', html_entity_decode( $filtered_subject ), $preferences );
        $filtered_subject = substr( $filtered_subject, strlen( 'Subject:' ) );
    }
    

    New code:

    
    if ( true === $do_enc )
    {
        /**
         * Enable UTF-8 characters in subject line
         * @since 1.9
         */
        if ( function_exists('mb_encode_mimeheader') )
        {
            $filtered_subject = mb_encode_mimeheader( html_entity_decode( $filtered_subject ), $preferences['input-charset'], $preferences['scheme'] );
        }
        elseif ( function_exists( 'iconv_mime_encode' ) )
        {
            $filtered_subject = iconv_mime_encode( 'Subject', html_entity_decode( $filtered_subject ), $preferences );
            $filtered_subject = substr( $filtered_subject, strlen( 'Subject: ' ) );
        }
    }
    

    It tries to use mb_encode_mimeheader() if that function is available. It is a bit different from what iconv_mime_encode() does and I’m not sure if it’ll work or not.

    Please let me know how it goes.

    Cheers,
    Vinny

    • This reply was modified 4 years, 2 months ago by useStrict. Reason: Removed extra indentation from code snippets
    Thread Starter kbaldac

    (@kbaldac)

    This code appears to have an error in it – the { below is flagged

    if ( function_exists('mb_encode_mimeheader') )
    {

    I am not a very experienced php coder, so don’t know what is wrong – I used copy and paste from your email

    karen

    Plugin Author useStrict

    (@usestrict)

    Hi Karen,

    Please make sure that the apostrophes haven’t been replaced by curly quotes or entities (that’s what I see in the email: ' instead of ‘).

    • This reply was modified 4 years, 2 months ago by useStrict.
    • This reply was modified 4 years, 2 months ago by useStrict. Reason: trying to show the entity instead of the character
    Plugin Author useStrict

    (@usestrict)

    It won’t let me write out the full entity. What I meant was & #039; (without the space)

    Thread Starter kbaldac

    (@kbaldac)

    Managed to get changes in the code ok and tested with UTF off and on

    Seemed to make no difference

    We appreciate your persistance but as long as we keep UTF off , the only time we get a problem is if a member uses double quote in the topic title. This happens rarely so we can live with it

    Karen

    Plugin Author useStrict

    (@usestrict)

    Thanks for working with me, Karen. I’ve posted a question in StackOverflow to see if anyone has any pointers.

    I’ll update this thread once I have something.

    Plugin Author useStrict

    (@usestrict)

    Hi @kbaldac,@matoca,

    It took me a while to track this one down, but I think I finally have a decent fix for it.

    Please update to v2.14 and let me know if you still see the issue.

    Cheers,
    Vinny

    Hi Vinny
    Your fix for the Subject line UTF-8 encoding error when using quotes works well. Many thanks for the work you put into it.
    Kind regards
    Robert Sterry [Guild of One-Name Studies Web Team]

Viewing 15 replies - 16 through 30 (of 31 total)
  • The topic ‘Subject line UTF-8 encoding’ is closed to new replies.