• I had to fix earlier version of this plugin manually – latest update, breaking again (destroys my whole page layout!) so needed to replicate fix.

    What I did was:
    File: email-before-download/includes/class-email-before-download-form.php
    Line: 35
    OLD:
    $form->loadHTML(mb_convert_encoding($raw, 'HTML-ENTITIES', 'UTF-8'));
    NEW:
    $form->loadHTML(htmlspecialchars_decode(utf8_decode(htmlentities($raw, ENT_COMPAT, 'utf-8', false))));

    Could this, or something equivalent go in the next release please, so I don’t keep having to patch it? Thx!

    P.S. I actually found some or all of this in another post somewhere, but I now can’t find it again, so can’t credit, sorry – but thank you whoever you are ??

    [Edited to show code properly]

    • This topic was modified 3 years, 9 months ago by wwwolf.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author mandsconsulting

    (@mandsconsulting)

    Hi @wwwolf,

    We have tried updating to the “new” code you are referencing in our local test environments, but we find this breaks certain sites that use non-English characters. Can you possibly provide more information that could help us understand how this “old” code is breaking your layout so we can come up with a fix that will work for you as well as and others? The “old” code doesn’t seem to break any layouts in the test environments we are using, so I am wondering if there might be an issue specific to certain themes.

    Thread Starter wwwolf

    (@wwwolf)

    That’s a pain – I must admit I got this solution off either another post here, or possibly from StackExchange (or similar) – I wish I could find the original reference.

    I am using Responsive Pro 2.16 with Page Builder by SiteOrigin … (and a slew of other plugins!) I could show you some screen grabs I took before and after it broke, if that would help, but don’t have time to ‘re-break it’ right now to see if I can see anything in the code. I’d create a staging copy for you to look at and break that, except that I’m having trouble with the staging environment too (possibly also due to the site’s relative complexity).

    I’ll have another look at the weekend and see if I can work out what’s going on – perhaps a stylesheet no longer loading or something. Meantime, how best to share the screen grabs?

    Thanks for your time on this ??

    • This reply was modified 3 years, 9 months ago by wwwolf.
    Plugin Author mandsconsulting

    (@mandsconsulting)

    Hi @wwwolf,

    Thanks for your willingness to help get to the bottom of this! We can try to pop in when/if you make the staging environment this weekend since that will allow us to reproduce the issue, troubleshoot, and try to fix if there is something we can change on our end to change.

    Thread Starter wwwolf

    (@wwwolf)

    Hi
    I’m puzzled that the ‘new code’ “breaks certain sites that use non-English characters” – as I understand it, that’s exactly what running htmlspecialchars_decode is supposed to avoid. However – see below for working ‘solution’!

    I created a staging site, tested it, then reverted my ‘fix’ and it not only broke the layout but produced a ‘critical error’ at the point where the first form loads, and stops rendering the rest of the page. Here’s the relevant segment of the error log (anonymised):

    [18-Jan-2021 16:12:30 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mb_convert_encoding() in /home/xxxxxxxx/mydomain.com/wp-new/wp-content/plugins/email-before-download/includes/class-email-before-download-form.php:35
    Stack trace:
    #0 /home/xxxxxxxx/mydomain.com/wp-new/wp-content/plugins/email-before-download/includes/class-email-before-download-shortcode.php(67): Email_Before_Download_Form->html()
    #1 /home/xxxxxxxx/mydomain.com/wp-new/wp-includes/shortcodes.php(343): Email_Before_Download_Shortcode->init_shortcode(Array, '', 'email-download')
    #2 [internal function]: do_shortcode_tag(Array)
    #3 /home/xxxxxxxx/mydomain.com/wp-new/wp-includes/shortcodes.php(218): preg_replace_callback('/\\[(\\[?)(email\\...', 'do_shortcode_ta...', '<div style='wid...')
    #4 /home/xxxxxxxx/mydomain.com/wp-new/wp-includes/class-wp-hook.php(287): do_shortcode('<div style='wid...')
    #5 /home/xxxxxxxx/mydomain.com/wp-new/wp-includes/plugin.php(212): WP_Hook->apply_filters('<div style=' in /home/xxxxxxxx/mydomain.com/wp-new/wp-content/plugins/email-before-download/includes/class-email-before-download-form.php on line 35
    [18-Jan-2021 16:12:47 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mb_convert_encoding() in /home/xxxxxxxx/mydomain.com/wp-new/wp-content/plugins/email-before-download/includes/class-email-before-download-form.php:35
    Stack trace:
    #0 /home/xxxxxxxx/mydomain.com/wp-new/wp-content/plugins/email-before-download/includes/class-email-before-download-shortcode.php(67): Email_Before_Download_Form->html()
    #1 /home/xxxxxxxx/mydomain.com/wp-new/wp-includes/shortcodes.php(343): Email_Before_Download_Shortcode->init_shortcode(Array, '', 'email-download')
    #2 [internal function]: do_shortcode_tag(Array)
    #3 /home/xxxxxxxx/mydomain.com/wp-new/wp-includes/shortcodes.php(218): preg_replace_callback('/\\[(\\[?)(email\\...', 'do_shortcode_ta...', '[email-download...')
    #4 /home/xxxxxxxx/mydomain.com/wp-new/wp-includes/class-wp-hook.php(289): do_shortcode('[email-download...')
    #5 /home/xxxxxxxx/mydomain.com/wp-new/wp-includes/plugin.php(212): WP_Hook->apply_filters('[email-downl in /home/xxxxxxxx/mydomain.com/wp-new/wp-content/plugins/email-before-download/includes/class-email-before-download-form.php on line 35
    

    I have now got the original (unedited) plugin working though – the clue was (a) the line ‘call to undefined function’ and (b) a comment in a StackExchange thread about needing the workaround because “the mb extension is not available on some environments“. I checked the php options in my hosting account and, sure enough, mbstring was not enabled! When I switched it on, cleared all the caches, and reloaded the pages (actual and test), everything worked.

    I don’t know how many hosts will not enable mbstring by default, but I know many are increasingly leaving OFF any extensions not considered in common use and which might offer slightly more risk of vulnerabilities, especially in a shared hosting environment. As recently as php 7.3 mbstring has suffered from buffer overflow vulnerabilities, hence likely caution. This may therefore start to happen more often.

    So… if anyone else finds that EBD completely breaks their site and throws this kind of error code, especially straight after a php update, the simple solution, if your host allows it, may well be to just enable mbstring in your php options ??

    @mandsconsultingIn theory, you should be able to avoid this happening to others by replicating the functionality of mb_convert_encoding in the manner I did but, as you have found out, there’s obviously still some kind of bug or feature that means they’re not in practice identical. Maybe some of the user notes in the php manual for the various functions might throw some light on this, but it’s well beyond me! Thanks for your timely engagement with this, wich gave me the confidence to do some more burrowing.

    Plugin Author mandsconsulting

    (@mandsconsulting)

    Hi @wwwolf,

    Thank you for the update and helping to get to the bottom of the issue. Glad you got your page working. In the meantime, we will try to look for a solution that doesn’t require enabling mbstring in PHP options.

    Finding this was a huge help. Thanks again!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Still a php error breaking my site – temp fix’ is closed to new replies.