WebsiteBaker Community Forum

WebsiteBaker Support (2.13.x) => Modules => Topic started by: Vlob on December 15, 2022, 01:30:50 AM

Title: mpFrom backend not saveable
Post by: Vlob on December 15, 2022, 01:30:50 AM
I encounter a problem with the mpform when I try to save the general settings

Code: [Select]
There was an uncatched exception
preg_match(): Argument #2 ($subject) must be of type string, bool given
in line (620) of (/framework/class.wb.php):

is what I get. doen anyone else have had this and possibly know how to solve this?
Title: Re: mpFrom backend not saveable
Post by: hgs on December 15, 2022, 08:55:24 AM
I have split the topic once, because it is a new problem
and
I can confirm the problem, but unfortunately do not have a solution.
It occurs with php7.4 to php8.1
Title: Re: mpFrom backend not saveable
Post by: Vlob on December 15, 2022, 10:04:37 AM
it is this part:
Code: [Select]
if (!$admin->validate_email($email_from)) {
    $email_from = '';
}
if (!$admin->validate_email($email_replyto)) {
    $email_replyto = '';
}
if (!$admin->validate_email($success_email_from)) {
    $success_email_from = '';
}
(mpform/save_settings.php line 142)

that needs this function:
Code: [Select]
    // Validate supplied email address
    public function validate_email($email) {

        if (\is_callable('\idn_to_ascii') && (\defined('INTL_IDNA_VARIANT_UTS46') || \defined('INTL_IDNA_VARIANT_2003'))){ /* use pear if available */
            $aInfoMatch = [];
            // 7.2.0  INTL_IDNA_VARIANT_2003 has been deprecated; use INTL_IDNA_VARIANT_UTS46 instead.
            $iVariant = \defined('INTL_IDNA_VARIANT_UTS46') ? \INTL_IDNA_VARIANT_UTS46 : \INTL_IDNA_VARIANT_2003;
            $email = \idn_to_ascii($email, 0, $iVariant);
        }else {

            $IDN = new idna_convert();
            $email = $IDN->encode($email);
            unset($IDN);
        }
        // regex from NorHei 2011-01-11
        $retval = \preg_match("/^((([!#$%&'*+\\-\/\=?^_`{|}~\w])|([!#$%&'*+\\-\/\=?^_`{|}~\w][!#$%&'*+\\-\/\=?^_`{|}~\.\w]{0,}[!#$%&'*+\\-\/\=?^_`{|}~\w]))[@]\w+(([-.]|\-\-)\w+)*\.\w+(([-.]|\-\-)\w+)*)$/", $email);
        return ($retval != false);
    }
(functions/class.wb.php line 605)

I guess the save_settings needs the validation in another way but I don't have a clue
Title: Re: mpFrom backend not saveable
Post by: Vlob on December 15, 2022, 10:24:34 AM
for now I took out this code from the save_settings.php (line 142)
Code: [Select]
if (($admin->validate_emailmpform($email_from)) != 'MailOk') {
    $email_from = '';
}
if (($admin->validate_emailmpform($email_replyto)) != 'MailOk') {
    $email_replyto = '';
}
if (($admin->validate_emailmpform($success_email_from)) != 'MailOk') {
    $success_email_from = '';
}

This makes it work agina but without a verification for the mail adresses.
Since my clients will not edit this and if they do I will drill them to test the form right after they alter the email adress I am fine with this for now but it still needs a fix I guess
Title: Re: mpFrom backend not saveable
Post by: hgs on December 15, 2022, 11:41:40 AM
For the problem, the development has created a patch on the fly. Please test it. The patch also fixes the error in the News and Form module when sorting with the mouse, which was posted in the forum. Thanks
If it works, the patch will be officially released.
Title: Re: mpFrom backend not saveable
Post by: hgs on December 15, 2022, 01:30:51 PM
Disadvantage of "on the fly" are more fixes that are noticeable when testing.

Here is the next version to test.