Postie - Version 1.9.23

Version Description

(2018-05-28) = * Fix issue when attachment doesn't conform to MIME standard

Download this release

Release Info

Developer WayneAllen
Plugin Icon 128x128 Postie
Version 1.9.23
Comparing to
See all releases

Code changes from version 1.9.22 to 1.9.23

docs/Changes.txt CHANGED
@@ -35,6 +35,12 @@ All script, style and body tags are stripped from html emails.
35
  Attachments are now processed in the order they were attached.
36
 
37
  == CHANGELOG ==
 
 
 
 
 
 
38
  = 1.9.21 (2018-05-08) =
39
  * Fix: WP is removing backslashes so double them up before saving
40
 
35
  Attachments are now processed in the order they were attached.
36
 
37
  == CHANGELOG ==
38
+ = 1.9.23 (2018-05-28) =
39
+ * Fix issue when attachment doesn't conform to MIME standard
40
+
41
+ = 1.9.22 (2018-05-28) =
42
+ * Remove Text for Message Start and Text for Message End defaults as they conflicted with some CSS
43
+
44
  = 1.9.21 (2018-05-08) =
45
  * Fix: WP is removing backslashes so double them up before saving
46
 
docs/Postie.txt CHANGED
@@ -7,7 +7,7 @@ Tags: e-mail, email, post-by-email
7
  Requires PHP: 5.3
8
  Requires at least: 4.0
9
  Tested up to: 4.9
10
- Stable tag: 1.9.22
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
7
  Requires PHP: 5.3
8
  Requires at least: 4.0
9
  Tested up to: 4.9
10
+ Stable tag: 1.9.23
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
lib/fMailbox.php CHANGED
@@ -232,9 +232,10 @@ class fMailbox {
232
  }
233
 
234
  $filename = '';
235
- $has_disposition = !empty($structure['disposition']);
236
 
237
- if ($has_disposition) {
 
238
  //ensure the mime type is correct before doing additional decoding. Some mail clients mark all attachments as text/plain regardless of real type - looking at you outlook.com
239
  foreach ($structure['disposition_fields'] as $field => $value) {
240
  if (strtolower($field) == 'filename') {
@@ -252,7 +253,7 @@ class fMailbox {
252
  }
253
  foreach ($structure['type_fields'] as $field => $value) {
254
  if (strtolower($field) == 'name') {
255
- //DebugEcho("handlePart: type_fields filename: $value");
256
  $filename = $value;
257
  $ftype = wp_check_filetype($filename);
258
  if ($ftype['type']) {
@@ -264,6 +265,8 @@ class fMailbox {
264
  break;
265
  }
266
  }
 
 
267
  }
268
 
269
  if ($structure['type'] == 'text') {
@@ -320,6 +323,7 @@ class fMailbox {
320
 
321
  // If the part doesn't have a disposition and is not the default text or html, set the disposition to inline
322
  if (!$has_disposition && ((!$is_text || !empty($info['text'])) && (!$is_html || !empty($info['html'])))) {
 
323
  $is_web_image = $structure['type'] == 'image' && in_array($structure['subtype'], array('gif', 'png', 'jpeg', 'pjpeg'));
324
  $structure['disposition'] = $is_text || $is_html || $is_web_image ? 'inline' : 'attachment';
325
  $structure['disposition_fields'] = array();
@@ -328,7 +332,7 @@ class fMailbox {
328
 
329
  // Attachments or inline content
330
  if ($has_disposition) {
331
- //DebugEcho("handlePart: disposition set to " . $structure['disposition']);
332
  // This automatically handles primary content that has a content-disposition header on it
333
  if ($structure['disposition'] == 'inline' && $filename === '') {
334
  //DebugEcho("handlePart: inline un-named");
@@ -366,7 +370,7 @@ class fMailbox {
366
  $info[$structure['disposition']] = array();
367
  }
368
 
369
- //DebugEcho("handlePart: disposition: '$filename' {$structure['type']}/{$structure['subtype']}");
370
  $info[$structure['disposition']][] = array(
371
  'filename' => $filename,
372
  'mimetype' => $structure['type'] . '/' . $structure['subtype'],
@@ -374,7 +378,7 @@ class fMailbox {
374
  );
375
  return $info;
376
  } else {
377
- //DebugEcho("handlePart: no disposition set");
378
  }
379
 
380
  if ($is_text) {
@@ -792,19 +796,17 @@ class fMailbox {
792
  'subtype' => $subtype,
793
  'parts' => array()
794
  );
795
- //Some email clients use boundary vs Boundary and PHP's array access is case sensitive so we have to check bothÏ
796
  $boundary = isset($headers['content-type']['fields']['boundary']) ? $headers['content-type']['fields']['boundary'] : $headers['content-type']['fields']['Boundary'];
797
  $start_pos = strpos($data, '--' . $boundary) + strlen($boundary) + 4;
798
  $end_pos = strrpos($data, '--' . $boundary . '--') - 2;
799
- $sub_contents = explode("\r\n--" . $boundary . "\r\n", substr(
800
- $data, $start_pos, $end_pos - $start_pos
801
- ));
802
  foreach ($sub_contents as $sub_content) {
803
  $structure['parts'][] = self::parseStructure($sub_content);
804
  }
 
 
805
  } else {
806
- //DebugEcho('parseStructure: content-type');
807
- //DebugDump($headers['content-type']);
808
  $structure = array(
809
  'type' => $type,
810
  'type_fields' => !empty($headers['content-type']['fields']) ? $headers['content-type']['fields'] : array(),
@@ -812,9 +814,12 @@ class fMailbox {
812
  'content_id' => isset($headers['content-id']) ? $headers['content-id'] : NULL,
813
  'encoding' => isset($headers['content-transfer-encoding']) ? strtolower($headers['content-transfer-encoding']) : '8bit',
814
  'disposition' => isset($headers['content-disposition']) ? strtolower($headers['content-disposition']['value']) : NULL,
815
- 'disposition_fields' => isset($headers['content-disposition']) ? $headers['content-disposition']['fields'] : array(),
816
- 'data' => $data
817
- );
 
 
 
818
  }
819
 
820
  return $structure;
232
  }
233
 
234
  $filename = '';
235
+ $has_disposition = !empty($structure['disposition']); // || !empty($structure['type_fields']);
236
 
237
+ if ($has_disposition || !empty($structure['type_fields'])) {
238
+ DebugEcho('handlePart: has_disposition');
239
  //ensure the mime type is correct before doing additional decoding. Some mail clients mark all attachments as text/plain regardless of real type - looking at you outlook.com
240
  foreach ($structure['disposition_fields'] as $field => $value) {
241
  if (strtolower($field) == 'filename') {
253
  }
254
  foreach ($structure['type_fields'] as $field => $value) {
255
  if (strtolower($field) == 'name') {
256
+ DebugEcho("handlePart: type_fields name: $value");
257
  $filename = $value;
258
  $ftype = wp_check_filetype($filename);
259
  if ($ftype['type']) {
265
  break;
266
  }
267
  }
268
+ } else {
269
+ //DebugEcho('handlePart: no disposition');
270
  }
271
 
272
  if ($structure['type'] == 'text') {
323
 
324
  // If the part doesn't have a disposition and is not the default text or html, set the disposition to inline
325
  if (!$has_disposition && ((!$is_text || !empty($info['text'])) && (!$is_html || !empty($info['html'])))) {
326
+ DebugEcho("handlePart: checking disposition");
327
  $is_web_image = $structure['type'] == 'image' && in_array($structure['subtype'], array('gif', 'png', 'jpeg', 'pjpeg'));
328
  $structure['disposition'] = $is_text || $is_html || $is_web_image ? 'inline' : 'attachment';
329
  $structure['disposition_fields'] = array();
332
 
333
  // Attachments or inline content
334
  if ($has_disposition) {
335
+ DebugEcho("handlePart: disposition set to " . $structure['disposition']);
336
  // This automatically handles primary content that has a content-disposition header on it
337
  if ($structure['disposition'] == 'inline' && $filename === '') {
338
  //DebugEcho("handlePart: inline un-named");
370
  $info[$structure['disposition']] = array();
371
  }
372
 
373
+ DebugEcho("handlePart: disposition: {$structure['disposition']} '$filename' {$structure['type']}/{$structure['subtype']}");
374
  $info[$structure['disposition']][] = array(
375
  'filename' => $filename,
376
  'mimetype' => $structure['type'] . '/' . $structure['subtype'],
378
  );
379
  return $info;
380
  } else {
381
+ DebugEcho("handlePart: no disposition set");
382
  }
383
 
384
  if ($is_text) {
796
  'subtype' => $subtype,
797
  'parts' => array()
798
  );
799
+ //Some email clients use boundary vs Boundary and PHP's array access is case sensitive so we have to check both
800
  $boundary = isset($headers['content-type']['fields']['boundary']) ? $headers['content-type']['fields']['boundary'] : $headers['content-type']['fields']['Boundary'];
801
  $start_pos = strpos($data, '--' . $boundary) + strlen($boundary) + 4;
802
  $end_pos = strrpos($data, '--' . $boundary . '--') - 2;
803
+ $sub_contents = explode("\r\n--" . $boundary . "\r\n", substr($data, $start_pos, $end_pos - $start_pos));
 
 
804
  foreach ($sub_contents as $sub_content) {
805
  $structure['parts'][] = self::parseStructure($sub_content);
806
  }
807
+ //DebugEcho('parseStructure: multipart');
808
+ //DebugDump($structure);
809
  } else {
 
 
810
  $structure = array(
811
  'type' => $type,
812
  'type_fields' => !empty($headers['content-type']['fields']) ? $headers['content-type']['fields'] : array(),
814
  'content_id' => isset($headers['content-id']) ? $headers['content-id'] : NULL,
815
  'encoding' => isset($headers['content-transfer-encoding']) ? strtolower($headers['content-transfer-encoding']) : '8bit',
816
  'disposition' => isset($headers['content-disposition']) ? strtolower($headers['content-disposition']['value']) : NULL,
817
+ 'disposition_fields' => isset($headers['content-disposition']) ? $headers['content-disposition']['fields'] : array());
818
+
819
+ DebugEcho('parseStructure: content-type');
820
+ DebugDump($structure);
821
+
822
+ $structure['data'] = $data;
823
  }
824
 
825
  return $structure;
postie-config.class.php CHANGED
@@ -165,8 +165,8 @@ class PostieConfig {
165
  'mail_userid' => NULL,
166
  'mail_password' => NULL,
167
  'maxemails' => 0,
168
- 'message_start' => ":start",
169
- 'message_end' => ":end",
170
  'message_encoding' => "UTF-8",
171
  'message_dequote' => true,
172
  'post_status' => 'publish',
165
  'mail_userid' => NULL,
166
  'mail_password' => NULL,
167
  'maxemails' => 0,
168
+ 'message_start' => "",
169
+ 'message_end' => "",
170
  'message_encoding' => "UTF-8",
171
  'message_dequote' => true,
172
  'post_status' => 'publish',
postie.class.php CHANGED
@@ -1220,7 +1220,7 @@ class Postie {
1220
  // then it should be removed
1221
  if (!$is_reply) {
1222
  wp_delete_post($post_id);
1223
- DebugEcho("postie_post filter cleared the post, not saving.");
1224
  }
1225
  } else {
1226
  $postid = $this->save_post($details, $is_reply);
1220
  // then it should be removed
1221
  if (!$is_reply) {
1222
  wp_delete_post($post_id);
1223
+ DebugEcho("postie_post filter cleared the post, not saving. deleted $post_id");
1224
  }
1225
  } else {
1226
  $postid = $this->save_post($details, $is_reply);
postie.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Create posts via email. Significantly upgrades the Post by Email features of WordPress.
7
- Version: 1.9.22
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL3
@@ -28,14 +28,14 @@
28
  */
29
 
30
  /*
31
- $Id: postie.php 1871161 2018-05-09 03:15:56Z WayneAllen $
32
  */
33
 
34
  if (!defined('WPINC')) {
35
  die; // Exit if accessed directly
36
  }
37
 
38
- define('POSTIE_VERSION', '1.9.22');
39
  define('POSTIE_ROOT', dirname(__FILE__));
40
  define('POSTIE_URL', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
41
 
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Create posts via email. Significantly upgrades the Post by Email features of WordPress.
7
+ Version: 1.9.23
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL3
28
  */
29
 
30
  /*
31
+ $Id: postie.php 1882922 2018-05-29 03:15:21Z WayneAllen $
32
  */
33
 
34
  if (!defined('WPINC')) {
35
  die; // Exit if accessed directly
36
  }
37
 
38
+ define('POSTIE_VERSION', '1.9.23');
39
  define('POSTIE_ROOT', dirname(__FILE__));
40
  define('POSTIE_URL', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
41
 
readme.txt CHANGED
@@ -7,7 +7,7 @@ Tags: e-mail, email, post-by-email
7
  Requires PHP: 5.3
8
  Requires at least: 4.0
9
  Tested up to: 4.9
10
- Stable tag: 1.9.21
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
@@ -107,7 +107,13 @@ All script, style and body tags are stripped from html emails.
107
  Attachments are now processed in the order they were attached.
108
 
109
  == CHANGELOG ==
110
- = 1.9.21 (2018-05-05) =
 
 
 
 
 
 
111
  * Fix: WP is removing backslashes so double them up before saving
112
 
113
  = 1.9.21 (2018-04-11) =
7
  Requires PHP: 5.3
8
  Requires at least: 4.0
9
  Tested up to: 4.9
10
+ Stable tag: 1.9.23
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
107
  Attachments are now processed in the order they were attached.
108
 
109
  == CHANGELOG ==
110
+ = 1.9.23 (2018-05-28) =
111
+ * Fix issue when attachment doesn't conform to MIME standard
112
+
113
+ = 1.9.22 (2018-05-28) =
114
+ * Remove Text for Message Start and Text for Message End defaults as they conflicted with some CSS
115
+
116
+ = 1.9.21 (2018-05-08) =
117
  * Fix: WP is removing backslashes so double them up before saving
118
 
119
  = 1.9.21 (2018-04-11) =