Postie - Version 1.4.12

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.12
Comparing to
See all releases

Code changes from version 1.4.11 to 1.4.12

config_form.php CHANGED
@@ -60,6 +60,10 @@
60
  }
61
  }
62
  extract($config);
 
 
 
 
63
 
64
  if ($interval == 'manual') {
65
  wp_clear_scheduled_hook('check_postie_hook');
@@ -164,7 +168,8 @@
164
  <input name='postie-settings[mail_password]' type="password" id='postie-settings-mail_password' value="<?php echo $mail_password; ?>" size="40" />
165
  </td>
166
  </tr>
167
- <tr><th>
 
168
  <?php _e('Check for mail every', 'postie') ?>
169
  </th>
170
  <td>
@@ -196,13 +201,26 @@
196
  ?>><?php _e('every ten minutes', 'postie') ?></option>
197
  <option value="manual" <?php
198
  if ($interval == "manual") {
199
- echo
200
- "selected='selected'";
201
  }
202
  ?>><?php _e('check manually', 'postie') ?></option>
203
  </select>
204
  </td>
205
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  <?php echo BuildBooleanSelect(__("Delete email after posting"), 'postie-settings[delete_mail_after_processing]', $delete_mail_after_processing, __("Only set to no for testing purposes")); ?>
207
  </table>
208
  </div>
60
  }
61
  }
62
  extract($config);
63
+ if (!isset($maxemails)) {
64
+ DebugEcho("New setting: maxemails");
65
+ $maxemails = 0;
66
+ }
67
 
68
  if ($interval == 'manual') {
69
  wp_clear_scheduled_hook('check_postie_hook');
168
  <input name='postie-settings[mail_password]' type="password" id='postie-settings-mail_password' value="<?php echo $mail_password; ?>" size="40" />
169
  </td>
170
  </tr>
171
+ <tr>
172
+ <th>
173
  <?php _e('Check for mail every', 'postie') ?>
174
  </th>
175
  <td>
201
  ?>><?php _e('every ten minutes', 'postie') ?></option>
202
  <option value="manual" <?php
203
  if ($interval == "manual") {
204
+ echo "selected='selected'";
 
205
  }
206
  ?>><?php _e('check manually', 'postie') ?></option>
207
  </select>
208
  </td>
209
  </tr>
210
+ <tr>
211
+ <th>
212
+ <?php _e('Maximum number of emails to process', 'postie'); ?>
213
+ </th>
214
+ <td>
215
+ <select name='postie-settings[maxemails]' id='postie-settings-maxemails'>
216
+ <option value="0" <?php if ($maxemails == '0') echo "selected='selected'" ?>>All</option>
217
+ <option value="5" <?php if ($maxemails == '5') echo "selected='selected'" ?>>5</option>
218
+ <option value="10" <?php if ($maxemails == '10') echo "selected='selected'" ?>>10</option>
219
+ <option value="25" <?php if ($maxemails == '25') echo "selected='selected'" ?>>25</option>
220
+ <option value="50" <?php if ($maxemails == '50') echo "selected='selected'" ?>>50</option>
221
+ </select>
222
+ </td>
223
+ </tr>
224
  <?php echo BuildBooleanSelect(__("Delete email after posting"), 'postie-settings[delete_mail_after_processing]', $delete_mail_after_processing, __("Only set to no for testing purposes")); ?>
225
  </table>
226
  </div>
deploy/_deploy.txt CHANGED
@@ -1,8 +1,9 @@
1
  see: http://codex.wordpress.org/Writing_a_Plugin#Updating_your_Plugin
2
  update docs\Changes.txt
3
- update version number in postie.php
4
- update version number in docs\postie.txt
5
  update date in docs\Changes.txt
 
 
 
6
  run deploy.cmd
7
  commit
8
  branch trunk to new version
1
  see: http://codex.wordpress.org/Writing_a_Plugin#Updating_your_Plugin
2
  update docs\Changes.txt
 
 
3
  update date in docs\Changes.txt
4
+ update Upgrade Notice in docs\Changes.txt
5
+ update version number in postie.php
6
+ update version number in docs\Postie.txt
7
  run deploy.cmd
8
  commit
9
  branch trunk to new version
docs/Changes.txt CHANGED
@@ -3,6 +3,10 @@
3
  * All script, style and body tags are stripped from html emails.
4
 
5
  == CHANGELOG ==
 
 
 
 
6
  = 1.4.11.(2012.12.14) =
7
  * Fixed bug where having a colon in the subject caused the subject to get truncated
8
  * Added donation link to admin screen
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
9
+
10
  = 1.4.11.(2012.12.14) =
11
  * Fixed bug where having a colon in the subject caused the subject to get truncated
12
  * Added donation link to admin screen
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.11
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.12
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
get_mail.php CHANGED
@@ -10,7 +10,7 @@ if (file_exists($wp_config_path . DIRECTORY_SEPARATOR . "wp-config.php")) {
10
 
11
  require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mimedecode.php');
12
  require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'postie-functions.php');
13
- if(!function_exists('file_get_html'))
14
  require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'simple_html_dom.php');
15
 
16
  if (!ini_get('safe_mode')) {
@@ -26,7 +26,10 @@ include('Revision');
26
  $test_email = null;
27
  $config = get_option('postie-settings');
28
  extract($config);
29
- $emails = FetchMail($mail_server, $mail_server_port, $mail_userid, $mail_password, $input_protocol, $time_offset, $test_email, $delete_mail_after_processing);
 
 
 
30
  $message = 'Done.';
31
 
32
  EchoInfo(sprintf(__("There are %d messages to process", "postie"), count($emails)));
10
 
11
  require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mimedecode.php');
12
  require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'postie-functions.php');
13
+ if (!function_exists('file_get_html'))
14
  require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'simple_html_dom.php');
15
 
16
  if (!ini_get('safe_mode')) {
26
  $test_email = null;
27
  $config = get_option('postie-settings');
28
  extract($config);
29
+ if (!isset($maxemails))
30
+ $maxemails = 0;
31
+
32
+ $emails = FetchMail($mail_server, $mail_server_port, $mail_userid, $mail_password, $input_protocol, $time_offset, $test_email, $delete_mail_after_processing, $maxemails);
33
  $message = 'Done.';
34
 
35
  EchoInfo(sprintf(__("There are %d messages to process", "postie"), count($emails)));
postie-functions.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /*
4
- $Id: postie-functions.php 639439 2012-12-14 22:03:09Z WayneAllen $
5
  */
6
 
7
  /* TODO
@@ -99,8 +99,12 @@ function LogInfo($v) {
99
  }
100
 
101
  function EchoInfo($v) {
102
- if (headers_sent()) {
103
- echo("<p>$v</p>\n");
 
 
 
 
104
  }
105
  LogInfo($v);
106
  }
@@ -108,12 +112,14 @@ function EchoInfo($v) {
108
  function DebugDump($v) {
109
  if (IsDebugMode()) {
110
  $o = print_r($v, true);
111
- if (headers_sent()) {
112
- echo "<pre>\n";
113
- }
114
- EchoInfo(htmlspecialchars($o));
115
- if (headers_sent()) {
116
- echo "</pre>\n";
 
 
117
  }
118
  }
119
  }
@@ -486,7 +492,7 @@ function ConfigurePostie() {
486
  * This function handles determining the protocol and fetching the mail
487
  * @return array
488
  */
489
- function FetchMail($server = NULL, $port = NULL, $email = NULL, $password = NULL, $protocol = NULL, $offset = NULL, $test = NULL, $deleteMessages = true) {
490
  $emails = array();
491
  if (!$server || !$port || !$email) {
492
  EchoInfo("Missing Configuration For Mail Server");
@@ -511,12 +517,12 @@ function FetchMail($server = NULL, $port = NULL, $email = NULL, $password = NULL
511
  if (!HasIMAPSupport()) {
512
  EchoInfo("Sorry - you do not have IMAP php module installed - it is required for this mail setting.");
513
  } else {
514
- $emails = IMAPMessageFetch($server, $port, $email, $password, $protocol, $offset, $test, $deleteMessages);
515
  }
516
  break;
517
  case 'pop3':
518
  default:
519
- $emails = POP3MessageFetch($server, $port, $email, $password, $protocol, $offset, $test, $deleteMessages);
520
  }
521
 
522
  return $emails;
@@ -525,7 +531,7 @@ function FetchMail($server = NULL, $port = NULL, $email = NULL, $password = NULL
525
  /**
526
  * Handles fetching messages from an imap server
527
  */
528
- function IMAPMessageFetch($server = NULL, $port = NULL, $email = NULL, $password = NULL, $protocol = NULL, $offset = NULL, $test = NULL, $deleteMessages = true) {
529
  require_once("postieIMAP.php");
530
  $emails = array();
531
  $mail_server = &PostieIMAP::Factory($protocol);
@@ -545,6 +551,10 @@ function IMAPMessageFetch($server = NULL, $port = NULL, $email = NULL, $password
545
  if ($deleteMessages) {
546
  $mail_server->deleteMessage($i);
547
  }
 
 
 
 
548
  }
549
  if ($deleteMessages) {
550
  $mail_server->expungeMessages();
@@ -557,7 +567,7 @@ function IMAPMessageFetch($server = NULL, $port = NULL, $email = NULL, $password
557
  /**
558
  * Retrieves email via POP3
559
  */
560
- function POP3MessageFetch($server = NULL, $port = NULL, $email = NULL, $password = NULL, $protocol = NULL, $offset = NULL, $test = NULL, $deleteMessages = true) {
561
  require_once(ABSPATH . WPINC . DIRECTORY_SEPARATOR . 'class-pop3.php');
562
 
563
  $emails = array();
@@ -588,6 +598,10 @@ function POP3MessageFetch($server = NULL, $port = NULL, $email = NULL, $password
588
  exit;
589
  }
590
  }
 
 
 
 
591
  }
592
  //clean up
593
  $pop3->quit();
@@ -1823,6 +1837,8 @@ function ReplaceImageCIDs(&$content, &$attachments) {
1823
  */
1824
  function ReplaceImagePlaceHolders(&$content, $attachments, $config) {
1825
  extract($config);
 
 
1826
  $startIndex = $start_image_count_at_zero ? 0 : 1;
1827
  if (!empty($attachments) && $auto_gallery) {
1828
  $imageTemplate = '[gallery]';
@@ -1850,24 +1866,22 @@ function ReplaceImagePlaceHolders(&$content, $attachments, $config) {
1850
  // look for caption
1851
  DebugEcho("Found $img_placeholder_temp or $eimg_placeholder_temp");
1852
  $caption = '';
1853
- $content = preg_replace("/&#0?39;/", "'", $content);
1854
- $content = preg_replace("/&(#0?34|quot);/", "\"", $content);
1855
- if (preg_match("/$img_placeholder_temp caption=['\"]?(.*?)['\"]?#/i", $content, $matches)) {
1856
- $caption = $matches[1];
1857
- DebugEcho("found caption: $caption");
1858
  $img_placeholder_temp = substr($matches[0], 0, -1);
1859
  $eimg_placeholder_temp = substr($matches[0], 0, -1);
1860
  } else {
1861
  DebugEcho("No caption found");
1862
  }
1863
  //DebugEcho("parameterize templete: " . htmlentities($imageTemplate));
1864
- $imageTemplate = mb_str_replace('{CAPTION}', $caption, $imageTemplate);
1865
- //DebugEcho("populated templete: " . htmlentities($imageTemplate));
1866
 
1867
  $img_placeholder_temp.='#';
1868
  $eimg_placeholder_temp.='#';
1869
 
1870
- //DebugEcho("replacing " . htmlentities($img_placeholder_temp) . " with template");
1871
  $content = str_ireplace($img_placeholder_temp, $imageTemplate, $content);
1872
  $content = str_ireplace($eimg_placeholder_temp, $imageTemplate, $content);
1873
  } else {
@@ -2179,6 +2193,7 @@ function get_postie_config_defaults() {
2179
  'mail_server_port' => 110,
2180
  'mail_userid' => NULL,
2181
  'mail_password' => NULL,
 
2182
  'message_start' => ":start",
2183
  'message_end' => ":end",
2184
  'message_encoding' => "UTF-8",
@@ -2275,8 +2290,7 @@ function GetDBConfig() {
2275
 
2276
  if (!isset($config["MESSAGE_END"]))
2277
  $config["MESSAGE_END"] = ":end";
2278
- if
2279
- (!isset($config["FORWARD_REJECTED_MAIL"]))
2280
  $config["FORWARD_REJECTED_MAIL"] = true;
2281
  if (!isset($config["RETURN_TO_SENDER"]))
2282
  $config["RETURN_TO_SENDER"] = false;
1
  <?php
2
 
3
  /*
4
+ $Id: postie-functions.php 640946 2012-12-18 05:44:52Z WayneAllen $
5
  */
6
 
7
  /* TODO
99
  }
100
 
101
  function EchoInfo($v) {
102
+ if (php_sapi_name() == "cli") {
103
+ echo "$v\n";
104
+ } else {
105
+ if (headers_sent()) {
106
+ echo "<p>" . htmlspecialchars($v) . "</p>\n";
107
+ }
108
  }
109
  LogInfo($v);
110
  }
112
  function DebugDump($v) {
113
  if (IsDebugMode()) {
114
  $o = print_r($v, true);
115
+ if (php_sapi_name() == "cli") {
116
+ echo "$o\n";
117
+ } else {
118
+ if (headers_sent()) {
119
+ echo "<pre>\n";
120
+ EchoInfo($o);
121
+ echo "</pre>\n";
122
+ }
123
  }
124
  }
125
  }
492
  * This function handles determining the protocol and fetching the mail
493
  * @return array
494
  */
495
+ function FetchMail($server = NULL, $port = NULL, $email = NULL, $password = NULL, $protocol = NULL, $offset = NULL, $test = NULL, $deleteMessages = true, $maxemails = 0) {
496
  $emails = array();
497
  if (!$server || !$port || !$email) {
498
  EchoInfo("Missing Configuration For Mail Server");
517
  if (!HasIMAPSupport()) {
518
  EchoInfo("Sorry - you do not have IMAP php module installed - it is required for this mail setting.");
519
  } else {
520
+ $emails = IMAPMessageFetch($server, $port, $email, $password, $protocol, $offset, $test, $deleteMessages, $maxemails);
521
  }
522
  break;
523
  case 'pop3':
524
  default:
525
+ $emails = POP3MessageFetch($server, $port, $email, $password, $protocol, $offset, $test, $deleteMessages, $maxemails);
526
  }
527
 
528
  return $emails;
531
  /**
532
  * Handles fetching messages from an imap server
533
  */
534
+ function IMAPMessageFetch($server = NULL, $port = NULL, $email = NULL, $password = NULL, $protocol = NULL, $offset = NULL, $test = NULL, $deleteMessages = true, $maxemails = 0) {
535
  require_once("postieIMAP.php");
536
  $emails = array();
537
  $mail_server = &PostieIMAP::Factory($protocol);
551
  if ($deleteMessages) {
552
  $mail_server->deleteMessage($i);
553
  }
554
+ if ($maxemails != 0 && $i >= $maxemails) {
555
+ DebugEcho("Max emails ($maxemails)");
556
+ break;
557
+ }
558
  }
559
  if ($deleteMessages) {
560
  $mail_server->expungeMessages();
567
  /**
568
  * Retrieves email via POP3
569
  */
570
+ function POP3MessageFetch($server = NULL, $port = NULL, $email = NULL, $password = NULL, $protocol = NULL, $offset = NULL, $test = NULL, $deleteMessages = true, $maxemails = 0) {
571
  require_once(ABSPATH . WPINC . DIRECTORY_SEPARATOR . 'class-pop3.php');
572
 
573
  $emails = array();
598
  exit;
599
  }
600
  }
601
+ if ($maxemails != 0 && $i >= $maxemails) {
602
+ DebugEcho("Max emails ($maxemails)");
603
+ break;
604
+ }
605
  }
606
  //clean up
607
  $pop3->quit();
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) {
1844
  $imageTemplate = '[gallery]';
1866
  // look for caption
1867
  DebugEcho("Found $img_placeholder_temp or $eimg_placeholder_temp");
1868
  $caption = '';
1869
+ if (preg_match("/$img_placeholder_temp caption=(.*?)#/i", $content, $matches)) {
1870
+ $caption = trim($matches[1]);
1871
+ $caption = substr($caption, 1, strlen($caption) - 2);
1872
+ DebugEcho("caption: $caption");
 
1873
  $img_placeholder_temp = substr($matches[0], 0, -1);
1874
  $eimg_placeholder_temp = substr($matches[0], 0, -1);
1875
  } else {
1876
  DebugEcho("No caption found");
1877
  }
1878
  //DebugEcho("parameterize templete: " . htmlentities($imageTemplate));
1879
+ $imageTemplate = mb_str_replace('{CAPTION}', htmlspecialchars($caption, ENT_QUOTES), $imageTemplate);
1880
+ //DebugEcho("populated templete: " . $imageTemplate);
1881
 
1882
  $img_placeholder_temp.='#';
1883
  $eimg_placeholder_temp.='#';
1884
 
 
1885
  $content = str_ireplace($img_placeholder_temp, $imageTemplate, $content);
1886
  $content = str_ireplace($eimg_placeholder_temp, $imageTemplate, $content);
1887
  } else {
2193
  'mail_server_port' => 110,
2194
  'mail_userid' => NULL,
2195
  'mail_password' => NULL,
2196
+ 'maxemails' => 0,
2197
  'message_start' => ":start",
2198
  'message_end' => ":end",
2199
  'message_encoding' => "UTF-8",
2290
 
2291
  if (!isset($config["MESSAGE_END"]))
2292
  $config["MESSAGE_END"] = ":end";
2293
+ if (!isset($config["FORWARD_REJECTED_MAIL"]))
 
2294
  $config["FORWARD_REJECTED_MAIL"] = true;
2295
  if (!isset($config["RETURN_TO_SENDER"]))
2296
  $config["RETURN_TO_SENDER"] = false;
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.11
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 639546 2012-12-15 05:05:41Z 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.12
8
  Author: Wayne Allen
9
  Author URI: http://allens-home.com/
10
  License: GPL2
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
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.11
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -358,6 +358,10 @@ 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.11.(2012.12.14) =
362
  * Fixed bug where having a colon in the subject caused the subject to get truncated
363
  * Added donation link to admin screen
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
  * 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
364
+
365
  = 1.4.11.(2012.12.14) =
366
  * Fixed bug where having a colon in the subject caused the subject to get truncated
367
  * Added donation link to admin screen
test/inlineimageTest.php CHANGED
@@ -130,8 +130,8 @@ class postiefunctions2Test extends PHPUnit_Framework_TestCase {
130
  }
131
 
132
  function testHandleMessageEncoding() {
133
- $e=HandleMessageEncoding('quoted-printable','iso-8859-7','<span style=3D"font-family:arial,sans-serif;font-size:13px">ABC=C3=C4=CEABC=</span><br>');
134
- $this->assertEquals('<span style="font-family:arial,sans-serif;font-size:13px">ABCΓΔΞABC=</span><br>',$e);
135
  }
136
 
137
  function testGreek() {
@@ -155,42 +155,49 @@ class postiefunctions2Test extends PHPUnit_Framework_TestCase {
155
  public function testReplaceImagePlaceHolders() {
156
  $c = "";
157
  $config = $this->standardConfig();
158
- $attachements = array("image.jpg" => 'template with {CAPTION}');
159
 
160
  ReplaceImagePlaceHolders($c, array(), $config);
161
  $this->assertEquals("", $c);
162
 
163
  ReplaceImagePlaceHolders($c, $attachements, $config);
164
- $this->assertEquals("template with ", $c);
165
 
166
  $c = "#img1#";
167
  ReplaceImagePlaceHolders($c, $attachements, $config);
168
- $this->assertEquals("template with ", $c);
169
 
170
  $c = "test #img1# test";
171
  ReplaceImagePlaceHolders($c, $attachements, $config);
172
- $this->assertEquals("test template with test", $c);
173
 
174
  $c = "test #img1 caption='1'# test";
175
  ReplaceImagePlaceHolders($c, $attachements, $config);
176
- $this->assertEquals("test template with 1 test", $c);
 
 
 
 
 
 
 
 
177
 
178
  $c = "test #img1 caption=\"I'd like some cheese.\"# test";
179
  ReplaceImagePlaceHolders($c, $attachements, $config);
180
- $this->assertEquals("test template with I'd like some cheese. test", $c);
181
-
182
  $c = "test #img1 caption=\"Eiskernbrecher mögens laut\"# test";
183
  ReplaceImagePlaceHolders($c, $attachements, $config);
184
- $this->assertEquals("test template with Eiskernbrecher mögens laut test", $c);
185
-
186
-
187
- $c = "test #img1 caption='[image-caption]'# test";
188
  ReplaceImagePlaceHolders($c, $attachements, $config);
189
- $this->assertEquals("test template with [image-caption] test", $c);
190
 
191
  $c = "test #img1 caption='1'# test #img2 caption='2'#";
192
  ReplaceImagePlaceHolders($c, $attachements, $config);
193
- $this->assertEquals("test template with 1 test #img2 caption='2'#", $c);
194
 
195
  $attachements = array("image1.jpg" => 'template with {CAPTION}', "image2.jpg" => 'template with {CAPTION}');
196
  $c = "test #img1 caption='1'# test #img2 caption='2'#";
130
  }
131
 
132
  function testHandleMessageEncoding() {
133
+ $e = HandleMessageEncoding('quoted-printable', 'iso-8859-7', '<span style=3D"font-family:arial,sans-serif;font-size:13px">ABC=C3=C4=CEABC=</span><br>');
134
+ $this->assertEquals('<span style="font-family:arial,sans-serif;font-size:13px">ABCΓΔΞABC=</span><br>', $e);
135
  }
136
 
137
  function testGreek() {
155
  public function testReplaceImagePlaceHolders() {
156
  $c = "";
157
  $config = $this->standardConfig();
158
+ $attachements = array("image.jpg" => '<img title="{CAPTION}" />');
159
 
160
  ReplaceImagePlaceHolders($c, array(), $config);
161
  $this->assertEquals("", $c);
162
 
163
  ReplaceImagePlaceHolders($c, $attachements, $config);
164
+ $this->assertEquals('<img title="" />', $c);
165
 
166
  $c = "#img1#";
167
  ReplaceImagePlaceHolders($c, $attachements, $config);
168
+ $this->assertEquals('<img title="" />', $c);
169
 
170
  $c = "test #img1# test";
171
  ReplaceImagePlaceHolders($c, $attachements, $config);
172
+ $this->assertEquals('test <img title="" /> test', $c);
173
 
174
  $c = "test #img1 caption='1'# test";
175
  ReplaceImagePlaceHolders($c, $attachements, $config);
176
+ $this->assertEquals('test <img title="1" /> test', $c);
177
+
178
+ $c = "test #img1 caption='! @ % ^ & * ( ) ~ \"Test\"'# test";
179
+ ReplaceImagePlaceHolders($c, $attachements, $config);
180
+ $this->assertEquals('test <img title="! @ % ^ &amp; * ( ) ~ &quot;Test&quot;" /> test', $c);
181
+
182
+ $c = "test <div>#img1 caption=&#39;! @ % ^ &amp; * ( ) ~ &quot;Test&quot;&#39;#</div> test";
183
+ ReplaceImagePlaceHolders($c, $attachements, $config);
184
+ $this->assertEquals("test <div><img title=\"! @ % ^ &amp; * ( ) ~ &quot;Test&quot;\" /></div> test", $c);
185
 
186
  $c = "test #img1 caption=\"I'd like some cheese.\"# test";
187
  ReplaceImagePlaceHolders($c, $attachements, $config);
188
+ $this->assertEquals('test <img title="I&#039;d like some cheese." /> test', $c);
189
+
190
  $c = "test #img1 caption=\"Eiskernbrecher mögens laut\"# test";
191
  ReplaceImagePlaceHolders($c, $attachements, $config);
192
+ $this->assertEquals('test <img title="Eiskernbrecher mögens laut" /> test', $c);
193
+
194
+ $c = "test #img1 caption='[image-caption]'# test";
 
195
  ReplaceImagePlaceHolders($c, $attachements, $config);
196
+ $this->assertEquals('test <img title="[image-caption]" /> test', $c);
197
 
198
  $c = "test #img1 caption='1'# test #img2 caption='2'#";
199
  ReplaceImagePlaceHolders($c, $attachements, $config);
200
+ $this->assertEquals('test <img title="1" /> test #img2 caption=\'2\'#', $c);
201
 
202
  $attachements = array("image1.jpg" => 'template with {CAPTION}', "image2.jpg" => 'template with {CAPTION}');
203
  $c = "test #img1 caption='1'# test #img2 caption='2'#";