Browse Source

Empty Strings Don't Need Cleanup Part 2

Revenge of the PHP 8.1, starring str_replace().
Andy 3 years ago
parent
commit
eebe84eab6
1 changed files with 7 additions and 3 deletions
  1. 7 3
      class/mime/Rfc822Header.class.php

+ 7 - 3
class/mime/Rfc822Header.class.php

@@ -1,4 +1,4 @@
-<?php
+`<?php
 
 
 /**
 /**
  * Rfc822Header.class.php
  * Rfc822Header.class.php
@@ -375,8 +375,12 @@ class Rfc822Header {
         $aTokens = array();
         $aTokens = array();
         $aSpecials = array('(' ,'<' ,',' ,';' ,':');
         $aSpecials = array('(' ,'<' ,',' ,';' ,':');
         $aReplace =  array(' (',' <',' ,',' ;',' :');
         $aReplace =  array(' (',' <',' ,',' ;',' :');
-        $address = str_replace($aSpecials,$aReplace,$address);
-        $iCnt = strlen($address);
+        if (!empty($address)) {
+            $address = str_replace($aSpecials,$aReplace,$address);
+            $iCnt = strlen($address);
+        } else {
+            $iCnt = 0;
+        }
         $i = 0;
         $i = 0;
         while ($i < $iCnt) {
         while ($i < $iCnt) {
             $cChar = $address[$i];
             $cChar = $address[$i];