浏览代码

Trimming NULL is Illegal Now

PHP 8.1 is pretty uppity for a typeless language.
Andy 3 年之前
父节点
当前提交
d82d4d586b
共有 1 个文件被更改,包括 33 次插入25 次删除
  1. 33 25
      src/compose.php

+ 33 - 25
src/compose.php

@@ -521,32 +521,34 @@ if ($send) {
          * of language interface.
          */
         set_my_charset();
-        /**
-         * This is to change all newlines to \n
-         * We'll change them to \r\n later (in the sendMessage function)
-         */
-        $body = str_replace("\r\n", "\n", $body);
-        $body = str_replace("\r", "\n", $body);
+        if ($body != null) {
+            /**
+             * This is to change all newlines to \n
+             * We'll change them to \r\n later (in the sendMessage function)
+             */
+            $body = str_replace("\r\n", "\n", $body);
+            $body = str_replace("\r", "\n", $body);
 
-        /**
-         * Rewrap $body so that no line is bigger than $editor_size
-         */
-        $body = explode("\n", $body);
-        $newBody = '';
-        foreach ($body as $line) {
-            if( $line <> '-- ' ) {
-                $line = rtrim($line);
-            }
-            if (sq_strlen($line, $default_charset) <= $editor_size + 1) {
-                $newBody .= $line . "\n";
-            } else {
-                sqWordWrap($line, $editor_size, $default_charset);
-                $newBody .= $line . "\n";
+            /**
+             * Rewrap $body so that no line is bigger than $editor_size
+             */
+            $body = explode("\n", $body);
+            $newBody = '';
+            foreach ($body as $line) {
+                if( $line <> '-- ' ) {
+                    $line = rtrim($line);
+                }
+                if (sq_strlen($line, $default_charset) <= $editor_size + 1) {
+                    $newBody .= $line . "\n";
+                } else {
+                    sqWordWrap($line, $editor_size, $default_charset);
+                    $newBody .= $line . "\n";
 
-            }
+                }
 
+            }
+            $body = $newBody;
         }
-        $body = $newBody;
 
         $Result = deliverMessage($composeMessage);
 
@@ -1621,9 +1623,15 @@ function checkInput ($show) {
      */
     global $send_to, $send_to_cc, $send_to_bcc;
 
-    $send_to = trim($send_to);
-    $send_to_cc = trim($send_to_cc);
-    $send_to_bcc = trim($send_to_bcc);
+    if (!empty($send_to)) {
+        $send_to = trim($send_to);
+    }
+    if (!empty($send_to_cc)) {
+        $send_to_cc = trim($send_to_cc);
+    }
+    if (!empty($send_to_bcc)) {
+        $send_to_bcc = trim($send_to_bcc);
+    }
     if (empty($send_to) && empty($send_to_cc) && empty($send_to_bcc)) {
         if ($show) {
             plain_error_message(_("You have not filled in the \"To:\" field."));