Contact Form by WPForms – Drag & Drop Form Builder for WordPress - Version 1.7.5.5

Version Description

  • Fixed: Migrations logic was broken in certain cases when addons have their own migrations.
  • Fixed: Security-related improvements around email generation for notifications.
Download this release

Release Info

Developer slaFFik
Plugin Icon 128x128 Contact Form by WPForms – Drag & Drop Form Builder for WordPress
Version 1.7.5.5
Comparing to
See all releases

Code changes from version 1.7.5.3 to 1.7.5.5

changelog.txt CHANGED
@@ -1,5 +1,9 @@
1
  == Changelog ==
2
 
 
 
 
 
3
  = 1.7.5.3 =
4
  - Added: New filter to modify CSS classes of the form submit button on the frontend.
5
  - Changed: Improve cached templates handling in the Form Builder.
1
  == Changelog ==
2
 
3
+ = 1.7.5.5 =
4
+ - Fixed: Migrations logic was broken in certain cases when addons have their own migrations.
5
+ - Fixed: Security-related improvements around email generation for notifications.
6
+
7
  = 1.7.5.3 =
8
  - Added: New filter to modify CSS classes of the form submit button on the frontend.
9
  - Changed: Improve cached templates handling in the Form Builder.
includes/admin/class-settings.php CHANGED
@@ -141,9 +141,12 @@ class WPForms_Settings {
141
  $value = (float) $value;
142
  break;
143
 
144
- case 'text':
145
  case 'radio':
146
  case 'select':
 
 
 
 
147
  default:
148
  $value = sanitize_text_field( $value );
149
  break;
@@ -652,6 +655,28 @@ class WPForms_Settings {
652
 
653
  $meta->create_table();
654
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
655
  }
656
 
657
  new WPForms_Settings();
141
  $value = (float) $value;
142
  break;
143
 
 
144
  case 'radio':
145
  case 'select':
146
+ $value = $this->validate_field_with_options( $field, $value, $value_prev );
147
+ break;
148
+
149
+ case 'text':
150
  default:
151
  $value = sanitize_text_field( $value );
152
  break;
655
 
656
  $meta->create_table();
657
  }
658
+
659
+ /**
660
+ * Validate radio and select fields.
661
+ *
662
+ * @since 1.7.5.5
663
+ *
664
+ * @param array $field Field.
665
+ * @param mixed $value Value.
666
+ * @param mixed $value_prev Previous value.
667
+ *
668
+ * @return mixed
669
+ */
670
+ private function validate_field_with_options( $field, $value, $value_prev ) {
671
+
672
+ $value = sanitize_text_field( $value );
673
+
674
+ if ( isset( $field['options'] ) && array_key_exists( $value, $field['options'] ) ) {
675
+ return $value;
676
+ }
677
+
678
+ return isset( $field['default'] ) ? $field['default'] : $value_prev;
679
+ }
680
  }
681
 
682
  new WPForms_Settings();
includes/emails/class-emails.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
 
 
3
  use WPForms\Tasks\Actions\EntryEmailsTask;
4
 
5
  /**
@@ -725,8 +726,14 @@ class WPForms_WP_Emails {
725
 
726
  // Try locating this template file by looping through the template paths.
727
  foreach ( $this->get_theme_template_paths() as $template_path ) {
728
- if ( file_exists( $template_path . $template_name ) ) {
729
- $located = $template_path . $template_name;
 
 
 
 
 
 
730
  break;
731
  }
732
  }
1
  <?php
2
 
3
+ use WPForms\Helpers\Templates;
4
  use WPForms\Tasks\Actions\EntryEmailsTask;
5
 
6
  /**
726
 
727
  // Try locating this template file by looping through the template paths.
728
  foreach ( $this->get_theme_template_paths() as $template_path ) {
729
+ $validated_path = Templates::validate_safe_path(
730
+ $template_path . $template_name,
731
+ [ 'theme', 'plugins' ]
732
+ );
733
+
734
+ if ( $validated_path ) {
735
+ $located = $validated_path;
736
+
737
  break;
738
  }
739
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: wpforms, jaredatch, smub, slaFFik
3
  Tags: contact form, contact form plugin, forms, form builder, custom form, contact button, contact me, custom contact form, form manager, form, forms builder, forms creator, captcha, recaptcha, Akismet, email form, web form, feedback form, payment form, survey form, donation form, email submit form, message form, mailchimp, mailchimp form, aweber, aweber form, paypal, paypal form, stripe, stripe form, getresponse, getresponse form, email subscription, contact form widget, user registration form, wordpress registration, wordpress login form, feedback
4
  Requires at least: 5.2
5
  Tested up to: 6.0
6
- Stable tag: 1.7.5.3
7
  Requires PHP: 5.6
8
  License: GNU General Public License v2.0 or later
9
 
@@ -429,6 +429,10 @@ Syed Balkhi
429
 
430
  == Changelog ==
431
 
 
 
 
 
432
  = 1.7.5.3 =
433
  - Added: New filter to modify CSS classes of the form submit button on the frontend.
434
  - Changed: Improve cached templates handling in the Form Builder.
3
  Tags: contact form, contact form plugin, forms, form builder, custom form, contact button, contact me, custom contact form, form manager, form, forms builder, forms creator, captcha, recaptcha, Akismet, email form, web form, feedback form, payment form, survey form, donation form, email submit form, message form, mailchimp, mailchimp form, aweber, aweber form, paypal, paypal form, stripe, stripe form, getresponse, getresponse form, email subscription, contact form widget, user registration form, wordpress registration, wordpress login form, feedback
4
  Requires at least: 5.2
5
  Tested up to: 6.0
6
+ Stable tag: 1.7.5.5
7
  Requires PHP: 5.6
8
  License: GNU General Public License v2.0 or later
9
 
429
 
430
  == Changelog ==
431
 
432
+ = 1.7.5.5 =
433
+ - Fixed: Migrations logic was broken in certain cases when addons have their own migrations.
434
+ - Fixed: Security-related improvements around email generation for notifications.
435
+
436
  = 1.7.5.3 =
437
  - Added: New filter to modify CSS classes of the form submit button on the frontend.
438
  - Changed: Improve cached templates handling in the Form Builder.
src/Helpers/Templates.php CHANGED
@@ -127,4 +127,99 @@ class Templates {
127
  self::include_html( $template_name, $args, $extract );
128
  return \ob_get_clean();
129
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  }
127
  self::include_html( $template_name, $args, $extract );
128
  return \ob_get_clean();
129
  }
130
+
131
+ /**
132
+ * Validate that a file path is safe and within the expected path(s).
133
+ *
134
+ * Author Scott Kingsley Clark, Pods Framework.
135
+ * Refactored to reduce cyclomatic complexity.
136
+ *
137
+ * @since 1.7.5.5
138
+ *
139
+ * @link https://github.com/pods-framework/pods/commit/ea53471e58e638dec06957edc38f9fa86607652c
140
+ *
141
+ * @param string $path The file path.
142
+ * @param null|array|string $paths_to_check The list of path types to check, defaults to just checking 'wpforms'.
143
+ * Available: 'wpforms', 'plugins', 'theme',
144
+ * or 'all' to check all supported paths.
145
+ *
146
+ * @return false|string False if the path was not allowed or did not exist, otherwise it returns the normalized path.
147
+ */
148
+ public static function validate_safe_path( $path, $paths_to_check = null ) {
149
+
150
+ static $available_checks;
151
+
152
+ if ( ! $available_checks ) {
153
+ $available_checks = [
154
+ 'wpforms' => realpath( WPFORMS_PLUGIN_DIR ),
155
+ 'plugins' => [
156
+ realpath( WP_PLUGIN_DIR ),
157
+ realpath( WPMU_PLUGIN_DIR ),
158
+ ],
159
+ 'theme' => [
160
+ realpath( get_stylesheet_directory() ),
161
+ realpath( get_template_directory() ),
162
+ ],
163
+ ];
164
+
165
+ $available_checks['plugins'] = array_unique( array_filter( $available_checks['plugins'] ) );
166
+ $available_checks['theme'] = array_unique( array_filter( $available_checks['theme'] ) );
167
+ $available_checks = array_filter( $available_checks );
168
+ }
169
+
170
+ $paths_to_check = $paths_to_check === null ? [ 'wpforms' ] : $paths_to_check;
171
+ $paths_to_check = $paths_to_check === 'all' ? array_keys( $available_checks ) : $paths_to_check;
172
+ $paths_to_check = (array) $paths_to_check;
173
+
174
+ if ( empty( $paths_to_check ) ) {
175
+ return false;
176
+ }
177
+
178
+ $path = wp_normalize_path( trim( (string) $path ) );
179
+
180
+ $match_count = 1;
181
+
182
+ // Replace the ../ usage as many times as it may need to be replaced.
183
+ while ( $match_count ) {
184
+ $path = str_replace( '../', '', $path, $match_count );
185
+ }
186
+
187
+ $path = realpath( $path );
188
+
189
+ foreach ( $paths_to_check as $check_type ) {
190
+ if ( self::has_match( $path, $available_checks, $check_type ) ) {
191
+ return $path;
192
+ }
193
+ }
194
+
195
+ return false;
196
+ }
197
+
198
+ /**
199
+ * Whether path matches.
200
+ *
201
+ * @since 1.7.5.5
202
+ *
203
+ * @param string|bool $path Path.
204
+ * @param array $available_checks Available checks.
205
+ * @param string $check_type Check type.
206
+ *
207
+ * @return bool
208
+ */
209
+ private static function has_match( $path, $available_checks, $check_type ) {
210
+
211
+ if ( ! $path || ! isset( $available_checks[ $check_type ] ) ) {
212
+ return false;
213
+ }
214
+
215
+ $check_type_paths = (array) $available_checks[ $check_type ];
216
+
217
+ foreach ( $check_type_paths as $path_to_check ) {
218
+ if ( 0 === strpos( $path, $path_to_check ) && file_exists( $path ) ) {
219
+ return true;
220
+ }
221
+ }
222
+
223
+ return false;
224
+ }
225
  }
src/Migrations/Base.php CHANGED
@@ -331,8 +331,9 @@ abstract class Base {
331
  * zero means completed earlier at unknown time,
332
  * positive means completion timestamp.
333
  */
334
- $this->migrated = get_option( static::MIGRATED_OPTION_NAME, [] );
335
 
 
336
  if ( is_array( $this->migrated ) ) {
337
  return;
338
  }
@@ -347,7 +348,6 @@ abstract class Base {
347
  */
348
  $this->migrated = get_option(
349
  str_replace( 'versions', 'version', static::MIGRATED_OPTION_NAME )
350
- []
351
  );
352
 
353
  $version = $this->migrated === false ? self::INITIAL_FAKE_VERSION : (string) $this->migrated;
331
  * zero means completed earlier at unknown time,
332
  * positive means completion timestamp.
333
  */
334
+ $this->migrated = get_option( static::MIGRATED_OPTION_NAME );
335
 
336
+ // If option is an array, it means that it is already converted to the new format.
337
  if ( is_array( $this->migrated ) ) {
338
  return;
339
  }
348
  */
349
  $this->migrated = get_option(
350
  str_replace( 'versions', 'version', static::MIGRATED_OPTION_NAME )
 
351
  );
352
 
353
  $version = $this->migrated === false ? self::INITIAL_FAKE_VERSION : (string) $this->migrated;
wpforms.php CHANGED
@@ -7,7 +7,7 @@
7
  * Requires PHP: 5.6
8
  * Author: WPForms
9
  * Author URI: https://wpforms.com
10
- * Version: 1.7.5.3
11
  * Text Domain: wpforms-lite
12
  * Domain Path: assets/languages
13
  *
@@ -36,7 +36,7 @@ if ( ! defined( 'WPFORMS_VERSION' ) ) {
36
  *
37
  * @since 1.0.0
38
  */
39
- define( 'WPFORMS_VERSION', '1.7.5.3' );
40
  }
41
 
42
  // Plugin Folder Path.
7
  * Requires PHP: 5.6
8
  * Author: WPForms
9
  * Author URI: https://wpforms.com
10
+ * Version: 1.7.5.5
11
  * Text Domain: wpforms-lite
12
  * Domain Path: assets/languages
13
  *
36
  *
37
  * @since 1.0.0
38
  */
39
+ define( 'WPFORMS_VERSION', '1.7.5.5' );
40
  }
41
 
42
  // Plugin Folder Path.