Patch to fix several problems in MagicHTML.
authorindiri69 <indiri69@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 27 Feb 2002 22:44:43 +0000 (22:44 +0000)
committerindiri69 <indiri69@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 27 Feb 2002 22:44:43 +0000 (22:44 +0000)
1. Now recognizes comments that dont have a space between <!-- and the text.
2. Fixed typo from EMBB to EMBE to handle EMBED tags.
3. Fixed BASE so it doesn't mangle BASEFONT tags.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2520 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/mime.php

index 92927d68f7a89cc5fa3f0a795397c9127694b5d2..580154b4f00f822ba96f7fc8ab8252818bfc0f0b 100644 (file)
@@ -905,10 +905,18 @@ function MagicHTML( $body, $id ) {
                 $tag .= $body{$pos};
                 $pos ++;
             }
+            /*
+               A comment in HTML is only three characters and isn't
+               guaranteed to have a space after it.  This fudges so
+               it will be caught by the switch statement.
+            */
+            if (ereg("!--", $tag)) {
+                $tag = "!-- ";
+            }
             switch( strtoupper( $tag ) ) {
             // Strips the entire tag and contents
             case 'APPL':
-            case 'EMBB':
+            case 'EMBE':
             case 'FRAM':
             case 'SCRI':
             case 'OBJE':
@@ -1023,8 +1031,21 @@ function MagicHTML( $body, $id ) {
                     $ret .= '<font color=#000000>';
                 break;
             case 'BASE':
-                $i += 5;
+                $i += 4;
                 $base = '';
+                if ( strncasecmp($body{$i}, 'font', 4) ) {
+                    $i += 5;
+                    while ( !isNoSep( $body{$i} ) && $i < $j ) {
+                        $i++;
+                    }
+                    while ( $body{$i} <> '>' && $i < $j ) {
+                            $base .= $body{$i};
+                        $i++;
+                    }
+                    $ret .= "<BASEFONT $base>\n";
+                    break;
+                }
+                $i++;
                 while ( !isNoSep( $body{$i} ) &&
                        $i < $j ) {
                         $i++;