Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/metform/build/admin/admin-shell/index.asset.php
+++ b/metform/build/admin/admin-shell/index.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('regenerator-runtime', 'wp-i18n'), 'version' => 'd5737adbaeb1a7ba5afd');
+<?php return array('dependencies' => array('regenerator-runtime', 'wp-i18n'), 'version' => '5154dd942db11a77d2c4');
--- a/metform/build/frontend/app/index.asset.php
+++ b/metform/build/frontend/app/index.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-element', 'wp-i18n'), 'version' => '9333eb211b508861c1b3');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-element', 'wp-i18n'), 'version' => '4daa268f9f52b7f7e0ac');
--- a/metform/core/admin/views/settings.php
+++ b/metform/core/admin/views/settings.php
@@ -4,7 +4,6 @@
use MetFormCoreAdminBase;
use MetFormPlugin;
-use MetFormCoreIntegrationsMail_Chimp;
use MetFormUtilsUtil;
use MetForm_ProBasePackage;
use MetForm_ProCoreIntegrationsPaymentPaypal;
@@ -1203,15 +1202,13 @@
<div class="mf-settings-section" id="mf-newsletter_integration">
<div class="mf-settings-single-section">
<div class="list-item">
- <?php if (class_exists(Mail_Chimp::class)) : ?>
- <div class="tab-header">
- <h4 class="list-item-header"><?php esc_html_e('Newsletter Integration', 'metform') ?></h4>
- </div>
+ <div class="tab-header">
+ <h4 class="list-item-header"><?php esc_html_e('Newsletter Integration', 'metform') ?></h4>
+ </div>
- <div class="mf-dashboard__settings-api-wrapper">
- <?php $news_letter_integration_function($settings); ?>
- </div>
- <?php endif; ?>
+ <div class="mf-dashboard__settings-api-wrapper">
+ <?php $news_letter_integration_function($settings); ?>
+ </div>
</div>
</div>
</div>
--- a/metform/core/compatibility/seo-plugin.php
+++ b/metform/core/compatibility/seo-plugin.php
@@ -29,6 +29,7 @@
// AIOSEO.
add_filter( 'aioseo_public_post_types', [ $this, 'exclude_post_types' ] );
+ add_filter( 'aioseo_page_builder_integration_disable', [ $this, 'disable_aioseo_page_builder' ], 10, 2 );
// Rank Math.
add_filter( 'rank_math/excluded_post_types', [ $this, 'exclude_post_types' ] );
@@ -50,6 +51,50 @@
}
/**
+ * Disable AIOSEO's page-builder integration for MetForm's internal post types.
+ *
+ * AIOSEO initializes its Elementor integration on every request and may try to
+ * read page-builder settings for these excluded post types. Besides being
+ * unnecessary, that can trigger a warning when no dynamic settings group was
+ * created for the post type.
+ *
+ * @param bool $disabled Whether the integration is disabled.
+ * @param string $integration_slug Page-builder integration slug.
+ * @return bool
+ */
+ public function disable_aioseo_page_builder( $disabled, $integration_slug ) {
+
+ if ( $disabled || 'elementor' !== $integration_slug ) {
+ return $disabled;
+ }
+
+ $post_type = '';
+
+ // phpcs:disable WordPress.Security.NonceVerification.Recommended
+ if ( isset( $_GET['post_type'] ) ) {
+ $post_type = sanitize_key( wp_unslash( $_GET['post_type'] ) );
+ }
+
+ if ( ! $post_type ) {
+ foreach ( [ 'post', 'post_id', 'id', 'metform_builder_canvas', 'preview_id' ] as $key ) {
+ if ( empty( $_GET[ $key ] ) ) {
+ continue;
+ }
+
+ $post_type = get_post_type( absint( wp_unslash( $_GET[ $key ] ) ) );
+ break;
+ }
+ }
+ // phpcs:enable WordPress.Security.NonceVerification.Recommended
+
+ if ( ! $post_type ) {
+ $post_type = get_post_type();
+ }
+
+ return in_array( $post_type, self::POST_TYPES, true );
+ }
+
+ /**
* Remove internal post types from supported lists.
*
* @param mixed $post_types Supported post types.
--- a/metform/core/entries/action.php
+++ b/metform/core/entries/action.php
@@ -14,7 +14,6 @@
private $key_form_id;
private $key_form_data;
//private $key_form_settings;
- private $key_browser_data;
private $key_form_total_entries;
private $key_form_file;
private $key_payment_status;
@@ -50,7 +49,6 @@
//$this->key_form_settings = 'metform_form__form_setting';
$this->key_form_total_entries = 'metform_form__form_total_entries';
- $this->key_browser_data = 'metform_form__entry_browser_data';
$this->key_form_id = 'metform_entries__form_id';
$this->key_form_data = 'metform_entries__form_data';
$this->key_form_file = 'metform_entries__file_upload_new';
@@ -60,8 +58,6 @@
public function submit($form_id, $form_data, $file_data, $page_id = '')
{
- error_log(print_r($form_data, true));
-
$hidden_fields = isset($form_data['hidden-fields']) ? json_decode($form_data['hidden-fields'], true) : [];
foreach ($hidden_fields as $key) {
@@ -280,30 +276,25 @@
}
}
- // user login check and action
- $required_loggin = isset($this->form_settings['require_login']) ? ((int) ($this->form_settings['require_login'])) : 0;
+ /**
+ * Lets an add-on block the submission before anything is stored.
+ * Return a WP_Error to block it: its code becomes the response
+ * failure_type and its message the error shown to the visitor.
+ *
+ * @param null|WP_Error $pre_check Null, or a WP_Error from an earlier callback.
+ * @param int $form_id
+ * @param array $form_data
+ * @param array $form_settings
+ */
+ $pre_check = apply_filters('metform/entries/submit/pre_check', null, $form_id, $form_data, $this->form_settings);
- error_log(print_r($this->form_settings, true));
- if (($required_loggin == 1) && (!is_user_logged_in())) {
+ if (is_wp_error($pre_check)) {
$this->response->status = 0;
- $this->response->failure_type = 'login_required';
- $this->response->error = [ esc_html__('You must be logged in to submit form.', 'metform') ];
+ $this->response->failure_type = $pre_check->get_error_code();
+ $this->response->error = [ $pre_check->get_error_message() ];
return $this->response;
}
- // Total entry limit check and prevent
- if (isset($this->form_settings['limit_total_entries_status'])) {
- $entry_limit = ((int) ($this->form_settings['limit_total_entries_status']));
-
- if (($entry_limit == 1) && ($this->get_entry_count() >= $this->form_settings['limit_total_entries'])) {
- $this->response->status = 0;
- $this->response->failure_type = 'entry_limit';
- $this->response->error = [ esc_html__('Form submission limit exceeded.', 'metform') ];
-
- return $this->response;
- }
- }
-
// signature input upload as image from base64
if (class_exists('MetForm_ProBasePackage') && isset($form_data['mf-signature'])) {
@@ -343,23 +334,16 @@
}
}
- // mailchimp email store action
- if (class_exists('MetFormCoreIntegrationsMail_Chimp')) {
- if (isset($this->form_settings['mf_mail_chimp']) && $this->form_settings['mf_mail_chimp'] == '1' && $this->email_name != null && $form_data[$this->email_name] != '') {
-
- $mail_chimp = new MetFormCoreIntegrationsMail_Chimp();
-
- if (array_key_exists("mf-listing-optin", $this->fields) && isset($form_data['mf-listing-optin'])) {
- $response = $mail_chimp->call_api($form_data, ['auth' => $this->form_settings, 'email_name' => $this->email_name]);
- } elseif (!array_key_exists('mf-listing-optin', $this->fields)) {
- $response = $mail_chimp->call_api($form_data, ['auth' => $this->form_settings, 'email_name' => $this->email_name]);
- }
-
- $this->response->status = isset($response['status']) ? $response['status'] : 0;
- if($this->response->status == 0) { $this->response->failure_type = 'integration'; $this->response->error = [ esc_html__('Problem with your mailchimp integration.', 'metform') ]; }
-
- }
- }
+ /**
+ * Lets an add-on send the submission to a third-party service.
+ * Runs before the entry is stored, so $context['entry_id'] is not set
+ * yet and $context['form_data'] is the submitted data as received.
+ * Callbacks report a failure on $response (status, failure_type, error).
+ *
+ * @param object $response The response sent back to the browser.
+ * @param array $context See get_hook_context().
+ */
+ do_action('metform/entries/submit/integrations', $this->response, $this->get_hook_context($form_data, $form_data));
// ActiveCampaign email store action
@@ -412,29 +396,6 @@
}
}
- // data submit to slack check and action
- if (class_exists('MetFormCoreIntegrationsSlack')) {
- if (isset($this->form_settings['mf_slack']) && $this->form_settings['mf_slack'] == '1' && $this->email_name != null && $form_data[$this->email_name] != '') {
-
- $url = $this->form_settings['mf_slack_webhook'];
-
- //$this->response->data['slack_hook'] = $url;
-
- if (array_key_exists('mf-listing-optin', $this->fields) && isset($form_data['mf-listing-optin'])) {
-
- $slack = new MetFormCoreIntegrationsSlack();
- $response = $slack->call_webhook($form_data, ['url' => $url, 'email_name' => $this->email_name]);
- } elseif (!array_key_exists('mf-listing-optin', $this->fields)) {
-
- $slack = new MetFormCoreIntegrationsSlack();
- $response = $slack->call_webhook($form_data, ['url' => $url, 'email_name' => $this->email_name]);
- }
-
- $this->response->status = isset($response['status']) ? $response['status'] : 0;
- if($this->response->status == 0) { $this->response->failure_type = 'integration'; $this->response->error = [ esc_html__('Problem with your slack integration.', 'metform') ]; }
- }
- }
-
/**
* Checking if convertKit is exists
* If exists calling the api
@@ -794,11 +755,15 @@
if($this->response->status == 0) { $this->response->failure_type = 'integration'; $this->response->error = [ esc_html__('Problem with your RestApi integration.', 'metform') ]; }
}
- // send confirmation email to user
- if (isset($this->form_settings['enable_user_notification']) && $this->form_settings['enable_user_notification'] == 1) {
-
- $this->send_user_email($this->form_data, $this->file_upload_info);
- }
+ /**
+ * Lets an add-on notify the submitter, for example with a confirmation email.
+ * $context['form_data'] is the sanitised data that was stored.
+ * Callbacks report a failure on $response (status, failure_type, error).
+ *
+ * @param object $response The response sent back to the browser.
+ * @param array $context See get_hook_context().
+ */
+ do_action('metform/entries/submit/notify_user', $this->response, $this->get_hook_context($this->form_data, $form_data));
// send notification email to admins
if (isset($this->form_settings['enable_admin_notification']) && $this->form_settings['enable_admin_notification'] == 1) {
@@ -1129,10 +1094,15 @@
update_post_meta($this->entry_id, $this->key_form_file, $this->file_upload_info);
- if (isset($form_settings['capture_user_browser_data']) && $form_settings['capture_user_browser_data'] == '1') {
- update_post_meta($this->entry_id, $this->key_browser_data, $this->get_browser_data());
- $this->response->status = 1;
- }
+ /**
+ * Fires after an entry and its form data are saved.
+ *
+ * @param int $entry_id
+ * @param int $form_id
+ * @param array $form_data Sanitised data that was stored.
+ * @param array $form_settings
+ */
+ do_action('metform/entries/after_insert', $this->entry_id, $form_id, $this->form_data, $form_settings);
// entries of logged in user data
if (is_user_logged_in()) {
@@ -1178,8 +1148,10 @@
* "user@site.comrnBcc: victim@site.com" would be parsed by wp_mail() as
* an additional header line, allowing arbitrary Bcc/Cc/header injection
* (email header / CRLF injection).
+ *
+ * Public so MetForm Pro uses this same function for its emails.
*/
- private function mf_sanitize_header_field($value)
+ public static function mf_sanitize_header_field($value)
{
$value = str_replace("