• Welcome to WebsiteBaker Community Forum. Please log in or sign up.
Welcome, Guest
News
Support WebsiteBaker
Your donations will help to:
PayPal
  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!
You can donate by clicking on the button below.

mpFrom backend not saveable

Started by Vlob, December 15, 2022, 01:30:50 AM  ( Read 13,831 times )

Vlob

I encounter a problem with the mpform when I try to save the general settings

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?

    hgs

    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
      LG Harald

      "Fange nie an, aufzuhören - höre nie auf, anzufangen." Marcus Tullius Cicero (106-43 v.Chr.)

      "Never begin to stop - never stop beginning." Marcus Tullius Cicero (106-43 BC)

      Vlob

      it is this part:
      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:
      // 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

        Vlob

        for now I took out this code from the save_settings.php (line 142)
        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

          hgs

          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.
            LG Harald

            "Fange nie an, aufzuhören - höre nie auf, anzufangen." Marcus Tullius Cicero (106-43 v.Chr.)

            "Never begin to stop - never stop beginning." Marcus Tullius Cicero (106-43 BC)

            hgs

            Disadvantage of "on the fly" are more fixes that are noticeable when testing.

            Here is the next version to test.
              LG Harald

              "Fange nie an, aufzuhören - höre nie auf, anzufangen." Marcus Tullius Cicero (106-43 v.Chr.)

              "Never begin to stop - never stop beginning." Marcus Tullius Cicero (106-43 BC)

              \n\n