Postie - Version 1.4.13

Version Description

  • Attachments are now processed in the order they were attached.
  • All script, style and body tags are stripped from html emails.
Download this release

Release Info

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

Code changes from version 1.4.12 to 1.4.13

Files changed (7) hide show
  1. Revision +2 -0
  2. docs/Changes.txt +3 -0
  3. docs/Postie.txt +1 -1
  4. get_mail.php +1 -0
  5. postie-functions.php +48 -15
  6. postie.php +2 -2
  7. readme.txt +4 -1
Revision CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ Revision: 643078
2
+ Last Changed Date: 2012-12-17 21:44:52 -0800 (Mon, 17 Dec 2012)
docs/Changes.txt CHANGED
@@ -3,6 +3,9 @@
3
  * All script, style and body tags are stripped from html emails.
4
 
5
  == CHANGELOG ==
 
 
 
6
  1.4.12 (2012.12.17) =
7
  * Added feature to limit the number of emails processed
8
  * Fixed bug where #img# was not processing the caption correctly
3
  * All script, style and body tags are stripped from html emails.
4
 
5
  == CHANGELOG ==
6
+ 1.4.13 (2012.12.26) =
7
+ * Fixed bug that was truncating content at the first html encoded character.
8
+
9
  1.4.12 (2012.12.17) =
10
  * Added feature to limit the number of emails processed
11
  * Fixed bug where #img# was not processing the caption correctly
docs/Postie.txt CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5
9
- Stable tag: 1.4.12
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5
9
+ Stable tag: 1.4.13
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
get_mail.php CHANGED
@@ -62,6 +62,7 @@ foreach ($emails as $email) {
62
  } else {
63
  EchoInfo("Ignoring email - not authorized.");
64
  }
 
65
  }
66
 
67
  if (function_exists('memory_get_usage'))
62
  } else {
63
  EchoInfo("Ignoring email - not authorized.");
64
  }
65
+ flush();
66
  }
67
 
68
  if (function_exists('memory_get_usage'))
postie-functions.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /*
4
- $Id: postie-functions.php 640946 2012-12-18 05:44:52Z WayneAllen $
5
  */
6
 
7
  /* TODO
@@ -158,10 +158,17 @@ function PostEmail($poster, $mimeDecodedEmail, $config) {
158
  //DebugEcho("the content is $content");
159
 
160
  $subject = GetSubject($mimeDecodedEmail, $content, $config);
 
161
 
162
  $customImages = SpecialMessageParsing($content, $attachments, $config);
 
 
163
  $post_excerpt = GetPostExcerpt($content, $filternewlines, $convertnewline);
 
 
164
  $postAuthorDetails = getPostAuthorDetails($subject, $content, $mimeDecodedEmail);
 
 
165
  $message_date = NULL;
166
  if (array_key_exists("date", $mimeDecodedEmail->headers) && !empty($mimeDecodedEmail->headers["date"])) {
167
  $cte = "";
@@ -175,15 +182,23 @@ function PostEmail($poster, $mimeDecodedEmail, $config) {
175
  $message_date = HandleMessageEncoding($cte, $cs, $mimeDecodedEmail->headers["date"], $message_encoding, $message_dequote);
176
  }
177
  list($post_date, $post_date_gmt, $delay) = DeterminePostDate($content, $message_date, $time_offset);
 
 
178
  ubb2HTML($content);
 
179
 
180
- if ($converturls)
181
  $content = clickableLink($content, $shortcode);
 
 
182
 
183
  $id = checkReply($subject);
184
  $post_categories = GetPostCategories($subject, $default_post_category);
185
  $post_tags = postie_get_tags($content, $default_post_tags);
 
 
186
  $comment_status = AllowCommentsOnPost($content);
 
187
 
188
  if ((empty($id) || is_null($id))) {
189
  $id = $post_id;
@@ -219,8 +234,10 @@ function PostEmail($poster, $mimeDecodedEmail, $config) {
219
  $content = $newContents;
220
  wp_delete_post($post_id);
221
  }
222
- if ($filternewlines)
223
  $content = FilterNewLines($content, $convertnewline);
 
 
224
 
225
  if ($delay != 0 && $post_status == 'publish') {
226
  $post_status = 'future';
@@ -674,7 +691,7 @@ function BannedFileName($filename, $bannedFiles) {
674
 
675
  function GetContent($part, &$attachments, $post_id, $poster, $config) {
676
  extract($config);
677
- global $charset, $encoding;
678
 
679
  $meta_return = '';
680
  DebugEcho("primary= " . $part->ctype_primary . ", secondary = " . $part->ctype_secondary);
@@ -729,12 +746,16 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
729
  break;
730
 
731
  case 'text':
732
- DebugDump($part);
 
 
 
733
  if (array_key_exists('charset', $part->ctype_parameters) && !empty($part->ctype_parameters['charset'])) {
734
  $charset = $part->ctype_parameters['charset'];
735
  DebugEcho("charset: $charset");
736
  }
737
 
 
738
  if (array_key_exists('content-transfer-encoding', $part->headers) && !empty($part->headers['content-transfer-encoding'])) {
739
  $encoding = $part->headers['content-transfer-encoding'];
740
  DebugEcho("encoding: $encoding");
@@ -765,7 +786,9 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
765
  }
766
  $meta_return = StripPGP($meta_return);
767
  $meta_return = "<div>$meta_return</div>\n";
 
768
  }
 
769
  break;
770
 
771
  case 'image':
@@ -915,15 +938,19 @@ function etf2HTML($content) {
915
  function HTML2HTML($content) {
916
  $html = str_get_html($content);
917
  if ($html) {
918
- // foreach ($html->find('script, style') as $node) {
919
- // $node->outertext = '';
920
- // }
921
- // $html->load($html->save());
 
 
922
 
923
  $b = $html->find('body');
924
  if ($b) {
925
  $content = "<div>" . $b[0]->innertext . "</div>\n";
926
  }
 
 
927
  }
928
  return $content;
929
  }
@@ -1837,7 +1864,9 @@ function ReplaceImageCIDs(&$content, &$attachments) {
1837
  */
1838
  function ReplaceImagePlaceHolders(&$content, $attachments, $config) {
1839
  extract($config);
1840
- $content = html_entity_decode($content, ENT_QUOTES);
 
 
1841
 
1842
  $startIndex = $start_image_count_at_zero ? 0 : 1;
1843
  if (!empty($attachments) && $auto_gallery) {
@@ -1948,7 +1977,7 @@ function GetSubject(&$mimeDecodedEmail, &$content, $config) {
1948
  }
1949
  if (!$allow_html_in_subject) {
1950
  DebugEcho("subject before htmlentities: $subject");
1951
- $subject = htmlentities($subject, ENT_COMPAT | ENT_HTML401, $message_encoding);
1952
  DebugEcho("subject after htmlentities: $subject");
1953
  }
1954
  }
@@ -2070,8 +2099,7 @@ function DisplayEmailPost($details) {
2070
  EchoInfo('Postname: ' . $details["post_name"]);
2071
  EchoInfo('Post Id: ' . $details["ID"]);
2072
  EchoInfo('Post Type: ' . $details["post_type"]); /* Added by Raam Dev <raam@raamdev.com> */
2073
- // EchoInfo('Posted content:');
2074
- // EchoInfo($details["post_content"]);
2075
  }
2076
 
2077
  /**
@@ -2639,27 +2667,32 @@ function SpecialMessageParsing(&$content, &$attachments, $config) {
2639
  }
2640
  if ($message_start) {
2641
  $content = StartFilter($content, $message_start);
 
2642
  }
2643
  if ($message_end) {
2644
  $content = EndFilter($content, $message_end);
 
2645
  }
2646
  if ($drop_signature) {
2647
  $content = remove_signature($content, $sig_pattern_list);
 
2648
  }
2649
  if ($prefer_text_type == "html" && count($attachments["cids"])) {
2650
  ReplaceImageCIDs($content, $attachments);
 
2651
  }
2652
  if (!$custom_image_field) {
2653
  ReplaceImagePlaceHolders($content, $attachments["html"], $config);
 
2654
  } else {
2655
  $customImages = array();
2656
- DebugEcho("Looking for custom images");
2657
  //DebugDump($attachments["html"]);
2658
 
2659
  foreach ($attachments["html"] as $key => $value) {
2660
  //DebugEcho("checking " . htmlentities($value));
2661
  if (preg_match("/src\s*=\s*['\"]([^'\"]*)['\"]/i", $value, $matches)) {
2662
- DebugEcho("found custom image: " . $matches[1]);
2663
  array_push($customImages, $matches[1]);
2664
  }
2665
  }
1
  <?php
2
 
3
  /*
4
+ $Id: postie-functions.php 644775 2012-12-26 19:43:03Z WayneAllen $
5
  */
6
 
7
  /* TODO
158
  //DebugEcho("the content is $content");
159
 
160
  $subject = GetSubject($mimeDecodedEmail, $content, $config);
161
+ //DebugEcho("post subject: $content");
162
 
163
  $customImages = SpecialMessageParsing($content, $attachments, $config);
164
+ //DebugEcho("post special message: $content");
165
+
166
  $post_excerpt = GetPostExcerpt($content, $filternewlines, $convertnewline);
167
+ //DebugEcho("post exerpt: $content");
168
+
169
  $postAuthorDetails = getPostAuthorDetails($subject, $content, $mimeDecodedEmail);
170
+ //DebugEcho("post author: $content");
171
+
172
  $message_date = NULL;
173
  if (array_key_exists("date", $mimeDecodedEmail->headers) && !empty($mimeDecodedEmail->headers["date"])) {
174
  $cte = "";
182
  $message_date = HandleMessageEncoding($cte, $cs, $mimeDecodedEmail->headers["date"], $message_encoding, $message_dequote);
183
  }
184
  list($post_date, $post_date_gmt, $delay) = DeterminePostDate($content, $message_date, $time_offset);
185
+ //DebugEcho("post date: $content");
186
+
187
  ubb2HTML($content);
188
+ //DebugEcho("post ubb: $content");
189
 
190
+ if ($converturls) {
191
  $content = clickableLink($content, $shortcode);
192
+ //DebugEcho("post clickable: $content");
193
+ }
194
 
195
  $id = checkReply($subject);
196
  $post_categories = GetPostCategories($subject, $default_post_category);
197
  $post_tags = postie_get_tags($content, $default_post_tags);
198
+ //DebugEcho("post tags: $content");
199
+
200
  $comment_status = AllowCommentsOnPost($content);
201
+ //DebugEcho("post comment: $content");
202
 
203
  if ((empty($id) || is_null($id))) {
204
  $id = $post_id;
234
  $content = $newContents;
235
  wp_delete_post($post_id);
236
  }
237
+ if ($filternewlines) {
238
  $content = FilterNewLines($content, $convertnewline);
239
+ //DebugEcho("post filter newlines: $content");
240
+ }
241
 
242
  if ($delay != 0 && $post_status == 'publish') {
243
  $post_status = 'future';
691
 
692
  function GetContent($part, &$attachments, $post_id, $poster, $config) {
693
  extract($config);
694
+ //global $charset, $encoding;
695
 
696
  $meta_return = '';
697
  DebugEcho("primary= " . $part->ctype_primary . ", secondary = " . $part->ctype_secondary);
746
  break;
747
 
748
  case 'text':
749
+ DebugEcho("ctype_primary: text");
750
+ //DebugDump($part);
751
+
752
+ $charset = "";
753
  if (array_key_exists('charset', $part->ctype_parameters) && !empty($part->ctype_parameters['charset'])) {
754
  $charset = $part->ctype_parameters['charset'];
755
  DebugEcho("charset: $charset");
756
  }
757
 
758
+ $encoding = "";
759
  if (array_key_exists('content-transfer-encoding', $part->headers) && !empty($part->headers['content-transfer-encoding'])) {
760
  $encoding = $part->headers['content-transfer-encoding'];
761
  DebugEcho("encoding: $encoding");
786
  }
787
  $meta_return = StripPGP($meta_return);
788
  $meta_return = "<div>$meta_return</div>\n";
789
+ //DebugEcho($meta_return);
790
  }
791
+ DebugEcho("----");
792
  break;
793
 
794
  case 'image':
938
  function HTML2HTML($content) {
939
  $html = str_get_html($content);
940
  if ($html) {
941
+ DebugEcho("Looking for invalid tags");
942
+ foreach ($html->find('script, style, head') as $node) {
943
+ DebugEcho("Removing: " . $node->outertext);
944
+ $node->outertext = '';
945
+ }
946
+ $html->load($html->save());
947
 
948
  $b = $html->find('body');
949
  if ($b) {
950
  $content = "<div>" . $b[0]->innertext . "</div>\n";
951
  }
952
+ } else {
953
+ DebugEcho("No HTML found");
954
  }
955
  return $content;
956
  }
1864
  */
1865
  function ReplaceImagePlaceHolders(&$content, $attachments, $config) {
1866
  extract($config);
1867
+ if (!$allow_html_in_body) {
1868
+ $content = html_entity_decode($content, ENT_QUOTES);
1869
+ }
1870
 
1871
  $startIndex = $start_image_count_at_zero ? 0 : 1;
1872
  if (!empty($attachments) && $auto_gallery) {
1977
  }
1978
  if (!$allow_html_in_subject) {
1979
  DebugEcho("subject before htmlentities: $subject");
1980
+ $subject = htmlentities($subject, ENT_COMPAT, $message_encoding);
1981
  DebugEcho("subject after htmlentities: $subject");
1982
  }
1983
  }
2099
  EchoInfo('Postname: ' . $details["post_name"]);
2100
  EchoInfo('Post Id: ' . $details["ID"]);
2101
  EchoInfo('Post Type: ' . $details["post_type"]); /* Added by Raam Dev <raam@raamdev.com> */
2102
+ //EchoInfo('Posted content: '.$details["post_content"]);
 
2103
  }
2104
 
2105
  /**
2667
  }
2668
  if ($message_start) {
2669
  $content = StartFilter($content, $message_start);
2670
+ //DebugEcho("post start: $content");
2671
  }
2672
  if ($message_end) {
2673
  $content = EndFilter($content, $message_end);
2674
+ //DebugEcho("post end: $content");
2675
  }
2676
  if ($drop_signature) {
2677
  $content = remove_signature($content, $sig_pattern_list);
2678
+ //DebugEcho("post signature: $content");
2679
  }
2680
  if ($prefer_text_type == "html" && count($attachments["cids"])) {
2681
  ReplaceImageCIDs($content, $attachments);
2682
+ //DebugEcho("post CIDs: $content");
2683
  }
2684
  if (!$custom_image_field) {
2685
  ReplaceImagePlaceHolders($content, $attachments["html"], $config);
2686
+ //DebugEcho("post placeholders: $content");
2687
  } else {
2688
  $customImages = array();
2689
+ //DebugEcho("Looking for custom images");
2690
  //DebugDump($attachments["html"]);
2691
 
2692
  foreach ($attachments["html"] as $key => $value) {
2693
  //DebugEcho("checking " . htmlentities($value));
2694
  if (preg_match("/src\s*=\s*['\"]([^'\"]*)['\"]/i", $value, $matches)) {
2695
+ //DebugEcho("found custom image: " . $matches[1]);
2696
  array_push($customImages, $matches[1]);
2697
  }
2698
  }
postie.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Signifigantly upgrades the posting by mail features of Word Press (See <a href='options-general.php?page=postie/postie.php'>Settings and options</a>) to configure your e-mail settings. See the <a href='http://wordpress.org/extend/plugins/postie/other_notes'>Readme</a> for usage. Visit the <a href='http://wordpress.org/support/plugin/postie'>postie forum</a> for support.
7
- Version: 1.4.12
8
  Author: Wayne Allen
9
  Author URI: http://allens-home.com/
10
  License: GPL2
@@ -27,7 +27,7 @@
27
  */
28
 
29
  /*
30
- $Id: postie.php 640946 2012-12-18 05:44:52Z WayneAllen $
31
  * -= Requests Pending =-
32
  * Problem with some mail server
33
  * Multiple emails should tie to a single account
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Signifigantly upgrades the posting by mail features of Word Press (See <a href='options-general.php?page=postie/postie.php'>Settings and options</a>) to configure your e-mail settings. See the <a href='http://wordpress.org/extend/plugins/postie/other_notes'>Readme</a> for usage. Visit the <a href='http://wordpress.org/support/plugin/postie'>postie forum</a> for support.
7
+ Version: 1.4.13
8
  Author: Wayne Allen
9
  Author URI: http://allens-home.com/
10
  License: GPL2
27
  */
28
 
29
  /*
30
+ $Id: postie.php 644775 2012-12-26 19:43:03Z WayneAllen $
31
  * -= Requests Pending =-
32
  * Problem with some mail server
33
  * Multiple emails should tie to a single account
readme.txt CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5
9
- Stable tag: 1.4.12
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -358,6 +358,9 @@ It is also possible to turn the WordPress cron off. Please make sure something l
358
  * All script, style and body tags are stripped from html emails.
359
 
360
  == CHANGELOG ==
 
 
 
361
  1.4.12 (2012.12.17) =
362
  * Added feature to limit the number of emails processed
363
  * Fixed bug where #img# was not processing the caption correctly
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5
9
+ Stable tag: 1.4.13
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
358
  * All script, style and body tags are stripped from html emails.
359
 
360
  == CHANGELOG ==
361
+ 1.4.13 (2012.12.26) =
362
+ * Fixed bug that was trucating content at the first html encoded character.
363
+
364
  1.4.12 (2012.12.17) =
365
  * Added feature to limit the number of emails processed
366
  * Fixed bug where #img# was not processing the caption correctly