Contact Form 7 - Version 4.6.1

Version Description

  • Fixed: "0" input could pass the minlength validation.
  • Fixed: exclude_blank option was applied to all mail fields, not only to the message body.
  • Fixed: wpcf7_autop() incorrectly inserted <br /> around hidden and block-type form-tags.
  • Fixed: Applying strtolower() to uploaded file names was unnecessary and could cause troubles in a non-English environment.
Download this release

Release Info

Developer takayukister
Plugin Icon 128x128 Contact Form 7
Version 4.6.1
Comparing to
See all releases

Code changes from version 4.6 to 4.6.1

includes/formatting.php CHANGED
@@ -54,11 +54,20 @@ function wpcf7_autop( $pee, $br = 1 ) {
54
  $pee = preg_replace_callback( '/<(script|style|textarea).*?<\/\\1>/s', create_function( '$matches', 'return str_replace("\n", "<WPPreserveNewline />", $matches[0]);' ), $pee );
55
  $pee = preg_replace( '|(?<!<br />)\s*\n|', "<br />\n", $pee ); // optionally make line breaks
56
  $pee = str_replace( '<WPPreserveNewline />', "\n", $pee );
 
 
 
 
57
  }
 
58
  $pee = preg_replace( '!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee );
59
  $pee = preg_replace( '!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee );
60
- if ( strpos( $pee, '<pre' ) !== false )
61
- $pee = preg_replace_callback( '!(<pre[^>]*>)(.*?)</pre>!is', 'clean_pre', $pee );
 
 
 
 
62
  $pee = preg_replace( "|\n</p>$|", '</p>', $pee );
63
 
64
  return $pee;
@@ -142,13 +151,18 @@ function wpcf7_strip_newline( $str ) {
142
  return trim( $str );
143
  }
144
 
145
- function wpcf7_canonicalize( $text ) {
146
  if ( function_exists( 'mb_convert_kana' )
147
  && 'UTF-8' == get_option( 'blog_charset' ) ) {
148
  $text = mb_convert_kana( $text, 'asKV', 'UTF-8' );
149
  }
150
 
151
- $text = strtolower( $text );
 
 
 
 
 
152
  $text = trim( $text );
153
  return $text;
154
  }
54
  $pee = preg_replace_callback( '/<(script|style|textarea).*?<\/\\1>/s', create_function( '$matches', 'return str_replace("\n", "<WPPreserveNewline />", $matches[0]);' ), $pee );
55
  $pee = preg_replace( '|(?<!<br />)\s*\n|', "<br />\n", $pee ); // optionally make line breaks
56
  $pee = str_replace( '<WPPreserveNewline />', "\n", $pee );
57
+
58
+ /* wpcf7: remove extra <br /> just added before [response], [recaptcha], and [hidden] tags */
59
+ $pee = preg_replace( '!<br />\n(\[' . $block_hidden_form_tags . '[^]]*\])!',
60
+ "\n$1", $pee );
61
  }
62
+
63
  $pee = preg_replace( '!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee );
64
  $pee = preg_replace( '!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee );
65
+
66
+ if ( strpos( $pee, '<pre' ) !== false ) {
67
+ $pee = preg_replace_callback( '!(<pre[^>]*>)(.*?)</pre>!is',
68
+ 'clean_pre', $pee );
69
+ }
70
+
71
  $pee = preg_replace( "|\n</p>$|", '</p>', $pee );
72
 
73
  return $pee;
151
  return trim( $str );
152
  }
153
 
154
+ function wpcf7_canonicalize( $text, $strto = 'lower' ) {
155
  if ( function_exists( 'mb_convert_kana' )
156
  && 'UTF-8' == get_option( 'blog_charset' ) ) {
157
  $text = mb_convert_kana( $text, 'asKV', 'UTF-8' );
158
  }
159
 
160
+ if ( 'lower' == $strto ) {
161
+ $text = strtolower( $text );
162
+ } elseif ( 'upper' == $strto ) {
163
+ $text = strtoupper( $text );
164
+ }
165
+
166
  $text = trim( $text );
167
  return $text;
168
  }
includes/mail.php CHANGED
@@ -35,18 +35,19 @@ class WPCF7_Mail {
35
 
36
  public function get( $component, $replace_tags = false ) {
37
  $use_html = ( $this->use_html && 'body' == $component );
 
 
38
  $template = $this->template;
39
  $component = isset( $template[$component] ) ? $template[$component] : '';
40
 
41
  if ( $replace_tags ) {
42
- if ( $use_html ) {
43
- $component = $this->replace_tags( $component, true );
 
44
 
45
- if ( ! preg_match( '%<html[>\s].*</html>%is', $component ) ) {
46
- $component = $this->htmlize( $component );
47
- }
48
- } else {
49
- $component = $this->replace_tags( $component );
50
  }
51
  }
52
 
@@ -110,10 +111,14 @@ class WPCF7_Mail {
110
  return wp_mail( $recipient, $subject, $body, $headers, $attachments );
111
  }
112
 
113
- public function replace_tags( $content, $html = false ) {
114
- $args = array(
115
- 'html' => $html,
116
- 'exclude_blank' => $this->exclude_blank );
 
 
 
 
117
 
118
  return wpcf7_mail_replace_tags( $content, $args );
119
  }
35
 
36
  public function get( $component, $replace_tags = false ) {
37
  $use_html = ( $this->use_html && 'body' == $component );
38
+ $exclude_blank = ( $this->exclude_blank && 'body' == $component );
39
+
40
  $template = $this->template;
41
  $component = isset( $template[$component] ) ? $template[$component] : '';
42
 
43
  if ( $replace_tags ) {
44
+ $component = $this->replace_tags( $component, array(
45
+ 'html' => $use_html,
46
+ 'exclude_blank' => $exclude_blank ) );
47
 
48
+ if ( $use_html
49
+ && ! preg_match( '%<html[>\s].*</html>%is', $component ) ) {
50
+ $component = $this->htmlize( $component );
 
 
51
  }
52
  }
53
 
111
  return wp_mail( $recipient, $subject, $body, $headers, $attachments );
112
  }
113
 
114
+ public function replace_tags( $content, $args = '' ) {
115
+ if ( true === $args ) {
116
+ $args = array( 'html' => true );
117
+ }
118
+
119
+ $args = wp_parse_args( $args, array(
120
+ 'html' => false,
121
+ 'exclude_blank' => false ) );
122
 
123
  return wpcf7_mail_replace_tags( $content, $args );
124
  }
license.txt CHANGED
@@ -1,4 +1,4 @@
1
- Contact Form 7 WordPress Plugin, 2007-2016 Takayuki Miyoshi
2
  Contact Form 7 is distributed under the terms of the GNU GPL
3
 
4
  This program is free software; you can redistribute it and/or modify
1
+ Contact Form 7 WordPress Plugin, 2007-2017 Takayuki Miyoshi
2
  Contact Form 7 is distributed under the terms of the GNU GPL
3
 
4
  This program is free software; you can redistribute it and/or modify
modules/file.php CHANGED
@@ -91,8 +91,9 @@ function wpcf7_file_validation_filter( $result, $tag ) {
91
  return $result;
92
  }
93
 
94
- if ( ! is_uploaded_file( $file['tmp_name'] ) )
95
  return $result;
 
96
 
97
  $allowed_file_types = array();
98
 
@@ -124,10 +125,11 @@ function wpcf7_file_validation_filter( $result, $tag ) {
124
  if ( ! empty( $matches[2] ) ) {
125
  $kbmb = strtolower( $matches[2] );
126
 
127
- if ( 'kb' == $kbmb )
128
  $allowed_size *= 1024;
129
- elseif ( 'mb' == $kbmb )
130
  $allowed_size *= 1024 * 1024;
 
131
  }
132
 
133
  break;
@@ -138,8 +140,9 @@ function wpcf7_file_validation_filter( $result, $tag ) {
138
  /* File type validation */
139
 
140
  // Default file-type restriction
141
- if ( '' == $file_type_pattern )
142
  $file_type_pattern = 'jpg|jpeg|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv';
 
143
 
144
  $file_type_pattern = trim( $file_type_pattern, '|' );
145
  $file_type_pattern = '(' . $file_type_pattern . ')';
@@ -162,7 +165,7 @@ function wpcf7_file_validation_filter( $result, $tag ) {
162
  $uploads_dir = wpcf7_maybe_add_random_dir( $uploads_dir );
163
 
164
  $filename = $file['name'];
165
- $filename = wpcf7_canonicalize( $filename );
166
  $filename = sanitize_file_name( $filename );
167
  $filename = wpcf7_antiscript_file_name( $filename );
168
  $filename = wp_unique_filename( $uploads_dir, $filename );
91
  return $result;
92
  }
93
 
94
+ if ( ! is_uploaded_file( $file['tmp_name'] ) ) {
95
  return $result;
96
+ }
97
 
98
  $allowed_file_types = array();
99
 
125
  if ( ! empty( $matches[2] ) ) {
126
  $kbmb = strtolower( $matches[2] );
127
 
128
+ if ( 'kb' == $kbmb ) {
129
  $allowed_size *= 1024;
130
+ } elseif ( 'mb' == $kbmb ) {
131
  $allowed_size *= 1024 * 1024;
132
+ }
133
  }
134
 
135
  break;
140
  /* File type validation */
141
 
142
  // Default file-type restriction
143
+ if ( '' == $file_type_pattern ) {
144
  $file_type_pattern = 'jpg|jpeg|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv';
145
+ }
146
 
147
  $file_type_pattern = trim( $file_type_pattern, '|' );
148
  $file_type_pattern = '(' . $file_type_pattern . ')';
165
  $uploads_dir = wpcf7_maybe_add_random_dir( $uploads_dir );
166
 
167
  $filename = $file['name'];
168
+ $filename = wpcf7_canonicalize( $filename, 'as-is' );
169
  $filename = sanitize_file_name( $filename );
170
  $filename = wpcf7_antiscript_file_name( $filename );
171
  $filename = wp_unique_filename( $uploads_dir, $filename );
modules/text.php CHANGED
@@ -145,7 +145,7 @@ function wpcf7_text_validation_filter( $result, $tag ) {
145
  }
146
  }
147
 
148
- if ( ! empty( $value ) ) {
149
  $maxlength = $tag->get_maxlength_option();
150
  $minlength = $tag->get_minlength_option();
151
 
145
  }
146
  }
147
 
148
+ if ( '' !== $value ) {
149
  $maxlength = $tag->get_maxlength_option();
150
  $minlength = $tag->get_minlength_option();
151
 
modules/textarea.php CHANGED
@@ -98,7 +98,7 @@ function wpcf7_textarea_validation_filter( $result, $tag ) {
98
  $result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
99
  }
100
 
101
- if ( ! empty( $value ) ) {
102
  $maxlength = $tag->get_maxlength_option();
103
  $minlength = $tag->get_minlength_option();
104
 
98
  $result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
99
  }
100
 
101
+ if ( '' !== $value ) {
102
  $maxlength = $tag->get_maxlength_option();
103
  $minlength = $tag->get_minlength_option();
104
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: takayukister
3
  Donate link: http://contactform7.com/donate/
4
  Tags: contact, form, contact form, feedback, email, ajax, captcha, akismet, multilingual
5
  Requires at least: 4.5
6
- Tested up to: 4.7
7
- Stable tag: 4.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -62,6 +62,13 @@ Do you have questions or issues with Contact Form 7? Use these support channels
62
 
63
  For more information, see [Releases](http://contactform7.com/category/releases/).
64
 
 
 
 
 
 
 
 
65
  = 4.6 =
66
 
67
  * Ajax loader: HTML markup changed to `<span>` to be easily customizable with CSS.
@@ -71,21 +78,3 @@ For more information, see [Releases](http://contactform7.com/category/releases/)
71
  * `default:shortcode_attr` form-tag option.
72
  * `WPCF7_Shortcode`, `WPCF7_ShortcodeManager`, `wpcf7_add_shortcode()`, `wpcf7_scan_shortcode()`, and some other classes and functions have become deprecated.
73
  * Removed all language files from the _languages_ folder. Translations have moved to [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/contact-form-7).
74
-
75
- = 4.5.1 =
76
-
77
- * Avoids JavaScript strict-mode errors seen with ill-designed themes.
78
- * Fixed a bug around reCAPTCHA's callback and expired-callback options.
79
- * Specifies cursor style for file uploading fields.
80
- * Corrects language tags for locale codes with modifying suffix like '_formal'.
81
- * Corrects wpcf7_is_rtl() output. Added 5 locales to the RTL locales list.
82
- * Language Packs: Language files for Portuguese (Brazil) (pt_BR) and Hebrew (he_IL) have been removed.
83
-
84
- = 4.5 =
85
-
86
- * The default contact form template is revised.
87
- * reCAPTCHA: Run grecaptcha.reset() after a submission.
88
- * The autocomplete option for form-tags and wpcf7_form_autocomplete filter hook are introduced to manage autocomplete attribute.
89
- * The config validator is revised. The wpcf7_config_validator_validate action hook is introduced to allow 3rd-party to cut in.
90
- * A bug in character count form-tag is fixed.
91
- * Language Packs: Language files for Danish (da_DK), Polish (pl_PL), and Czech (cs_CZ) have been removed from the plugin package.
3
  Donate link: http://contactform7.com/donate/
4
  Tags: contact, form, contact form, feedback, email, ajax, captcha, akismet, multilingual
5
  Requires at least: 4.5
6
+ Tested up to: 4.7.1
7
+ Stable tag: 4.6.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
62
 
63
  For more information, see [Releases](http://contactform7.com/category/releases/).
64
 
65
+ = 4.6.1 =
66
+
67
+ * Fixed: "0" input could pass the `minlength` validation.
68
+ * Fixed: `exclude_blank` option was applied to all mail fields, not only to the message body.
69
+ * Fixed: `wpcf7_autop()` incorrectly inserted `<br />` around hidden and block-type form-tags.
70
+ * Fixed: Applying `strtolower()` to uploaded file names was unnecessary and could cause troubles in a non-English environment.
71
+
72
  = 4.6 =
73
 
74
  * Ajax loader: HTML markup changed to `<span>` to be easily customizable with CSS.
78
  * `default:shortcode_attr` form-tag option.
79
  * `WPCF7_Shortcode`, `WPCF7_ShortcodeManager`, `wpcf7_add_shortcode()`, `wpcf7_scan_shortcode()`, and some other classes and functions have become deprecated.
80
  * Removed all language files from the _languages_ folder. Translations have moved to [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/contact-form-7).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wp-contact-form-7.php CHANGED
@@ -7,10 +7,10 @@ Author: Takayuki Miyoshi
7
  Author URI: http://ideasilo.wordpress.com/
8
  Text Domain: contact-form-7
9
  Domain Path: /languages/
10
- Version: 4.6
11
  */
12
 
13
- define( 'WPCF7_VERSION', '4.6' );
14
 
15
  define( 'WPCF7_REQUIRED_WP_VERSION', '4.5' );
16
 
7
  Author URI: http://ideasilo.wordpress.com/
8
  Text Domain: contact-form-7
9
  Domain Path: /languages/
10
+ Version: 4.6.1
11
  */
12
 
13
+ define( 'WPCF7_VERSION', '4.6.1' );
14
 
15
  define( 'WPCF7_REQUIRED_WP_VERSION', '4.5' );
16