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 ??
@mandsconsulting – In 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.