Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/postie/lib/fMailbox.php
+++ b/postie/lib/fMailbox.php
@@ -297,12 +297,20 @@
}
// This indicates a content-id which is used for multipart/related
- if ($structure['content_id'] && $structure['type'] != 'text') {
+ $cid = '';
+ if (!empty($structure['content_id'])) {
+ $cid = trim($structure['content_id']);
+ if (substr($cid, 0, 1) === '<' && substr($cid, -1) === '>') {
+ $cid = substr($cid, 1, -1);
+ }
+ $cid = trim($cid);
+ }
+
+ if ($cid !== '' && $structure['type'] != 'text') {
//DebugEcho('handlePart: multipart/related: ' . $structure['content_id']);
if (!isset($info['related'])) {
$info['related'] = array();
}
- $cid = $structure['content_id'][0] == '<' ? substr($structure['content_id'], 1, -1) : $structure['content_id'];
//DebugEcho("handlePart: cid: $cid ($filename) {$structure['type']}/{$structure['subtype']}");
$info['related']['cid:' . $cid] = array(
'filename' => $filename,
@@ -812,11 +820,22 @@
//DebugEcho('parseStructure: multipart');
//DebugDump($structure);
} else {
+ $content_id = isset($headers['content-id']) ? trim($headers['content-id']) : NULL;
+ if ($content_id !== NULL) {
+ $clean_cid = $content_id;
+ if (substr($clean_cid, 0, 1) === '<' && substr($clean_cid, -1) === '>') {
+ $clean_cid = substr($clean_cid, 1, -1);
+ }
+ if (trim($clean_cid) === '') {
+ $content_id = NULL;
+ }
+ }
+
$structure = array(
'type' => $type,
'type_fields' => !empty($headers['content-type']['fields']) ? $headers['content-type']['fields'] : array(),
'subtype' => $subtype,
- 'content_id' => isset($headers['content-id']) ? $headers['content-id'] : NULL,
+ 'content_id' => $content_id,
'encoding' => isset($headers['content-transfer-encoding']) ? strtolower($headers['content-transfer-encoding']) : '8bit',
'disposition' => isset($headers['content-disposition']) ? strtolower($headers['content-disposition']['value']) : NULL,
'disposition_fields' => isset($headers['content-disposition']) ? $headers['content-disposition']['fields'] : array());
--- a/postie/lib/pConnection.php
+++ b/postie/lib/pConnection.php
@@ -56,6 +56,10 @@
abstract function isPersistant();
+ public function fetchMessageSource($uid) {
+ return null;
+ }
+
public function getMailbox() {
return $this->mailbox;
}
--- a/postie/lib/pCurlConnection.php
+++ b/postie/lib/pCurlConnection.php
@@ -144,4 +144,73 @@
public function isPersistant() {
return false;
}
+
+ public function buildFetchUrl($uid) {
+ if ($this->type == 'imap') {
+ $mailbox = trim($this->mailbox, '/');
+ if ($mailbox === '') {
+ $mailbox = 'INBOX';
+ }
+ return ($this->secure ? 'imaps' : 'imap') . '://' . $this->host . '/' . $mailbox . '/;UID=' . $uid;
+ }
+
+ return ($this->secure ? 'pop3s' : 'pop3') . '://' . $this->host . '/' . $uid;
+ }
+
+ public function fetchMessageSource($uid) {
+ $url = $this->buildFetchUrl($uid);
+ return $this->executeFetch($url, $uid);
+ }
+
+ protected function executeFetch($url, $uid) {
+ DebugEcho("curl fetch: $url");
+
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_USERPWD, "$this->username:$this->password");
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_PORT, $this->port);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+ curl_setopt($ch, CURLOPT_HEADER, false);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout);
+ curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
+
+ $fp = fopen('php://temp', 'w+');
+ curl_setopt($ch, CURLOPT_WRITEFUNCTION, function ($ch, $data) use ($fp) {
+ return fwrite($fp, $data);
+ });
+
+ $headers = array();
+ curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($ch, $header) use (&$headers) {
+ $headers[] = $header;
+ return strlen($header);
+ });
+
+ curl_setopt($ch, CURLOPT_VERBOSE, true);
+ $verbose = fopen('php://temp', 'w+');
+ curl_setopt($ch, CURLOPT_STDERR, $verbose);
+
+ $res = curl_exec($ch);
+
+ rewind($verbose);
+ $verboseLog = stream_get_contents($verbose);
+ DebugEcho("curl log: $verboseLog");
+ fclose($verbose);
+
+ if (false === $res) {
+ $error = curl_error($ch);
+ $errno = curl_errno($ch);
+ DebugEcho("Curl fetch error: $error ($errno)");
+ fclose($fp);
+ curl_close($ch);
+ throw new fConnectivityException('Unable to fetch message %1$s from %2$s server %3$s on port %4$s: %5$s', $uid, strtoupper($this->type), $this->host, $this->port, $error);
+ }
+
+ curl_close($ch);
+
+ rewind($fp);
+ $message = stream_get_contents($fp);
+ fclose($fp);
+
+ return $message;
+ }
}
--- a/postie/lib/pImapMailServer.php
+++ b/postie/lib/pImapMailServer.php
@@ -72,6 +72,11 @@
function fetchMessageSource($uid) {
+ $source = $this->connection->fetchMessageSource($uid);
+ if ($source !== null) {
+ return $source;
+ }
+
$response = $this->connection->write('UID FETCH ' . $uid . ' (BODY[])');
$j = 0;
--- a/postie/lib/pPop3MailServer.php
+++ b/postie/lib/pPop3MailServer.php
@@ -28,6 +28,11 @@
}
public function fetchMessageSource($uid) {
+ $source = $this->connection->fetchMessageSource($uid);
+ if ($source !== null) {
+ return $source;
+ }
+
$response = $this->connection->write('RETR ' . $uid);
array_shift($response);
$response = join("rn", $response);
--- a/postie/postie-filters.php
+++ b/postie/postie-filters.php
@@ -496,6 +496,9 @@
if (count($email['related'])) {
DebugEcho("filter_ReplaceImageCIDs: # CID attachments: " . count($email['related']));
foreach ($email['related'] as $cid => &$attachment) {
+ if ($cid === '' || $cid === 'cid:' || trim($cid) === 'cid:') {
+ continue;
+ }
if (false !== stripos($content, $cid)) {
DebugEcho("filter_ReplaceImageCIDs: CID: $cid");
if (isset($attachment['wp_id'])) {
--- a/postie/postie-message.php
+++ b/postie/postie-message.php
@@ -84,12 +84,7 @@
global $postie_post;
$postie_post = $details;
- //fix quoting
$content = $postie_post['post_content'];
- $char = array('"', '‘', '’', '“', '”', '′', '″');
- $replace = array('"', "'", "'", '"', '"', "'", '"');
- $content = str_replace($char, $replace, $content);
-
$newcontent = do_shortcode($content);
$details = $postie_post; // need to copy values back in case a shortcode modified them
$details['post_content'] = $newcontent;
--- a/postie/postie.class.php
+++ b/postie/postie.class.php
@@ -535,6 +535,9 @@
}
function log_onscreen($data) {
+ if ((function_exists('wp_doing_ajax') && wp_doing_ajax()) || (defined('DOING_AJAX') && DOING_AJAX)) {
+ return;
+ }
if (php_sapi_name() == 'cli') {
echo esc_html($data) . "n";
} else {
--- a/postie/postie.php
+++ b/postie/postie.php
@@ -4,7 +4,7 @@
Plugin Name: Postie
Plugin URI: http://PostiePlugin.com/
Description: Create posts via email. Significantly upgrades the Post by Email features of WordPress.
- Version: 1.9.91
+ Version: 1.9.92
Author: Wayne Allen
Author URI: http://PostiePlugin.com/
License: GPL3
@@ -28,7 +28,7 @@
*/
/*
- $Id: postie.php 3798962 2026-11-12 17:43:21Z WayneAllen $
+ $Id: postie.php 3821111 2026-11-24 17:30:41Z WayneAllen $
*/
if (!defined('WPINC')) {
@@ -50,6 +50,8 @@
class PostieInit {
+ private static $is_logging_query = false;
+
public function __construct() {
//WordPress Actions
add_action('init', array($this, 'init_action'), 20);
@@ -145,8 +147,13 @@
}
function query_filter($query) {
- if (Postie::is_debugmode()) {
- DebugEcho("Query: $query");
+ if (!self::$is_logging_query && Postie::is_debugmode()) {
+ self::$is_logging_query = true;
+ try {
+ DebugEcho("Query: $query");
+ } finally {
+ self::$is_logging_query = false;
+ }
}
return $query;
@@ -318,6 +325,7 @@
$raw_output = ob_get_clean();
remove_action('postie_log_debug', $log_collector);
+ remove_filter('query', array($this, 'query_filter'));
$duration = round(microtime(true) - $start_time, 2);
@@ -390,6 +398,7 @@
$raw_output = ob_get_clean();
remove_action('postie_log_debug', $log_collector);
+ remove_filter('query', array($this, 'query_filter'));
$duration = round(microtime(true) - $start_time, 2);