Browse Source

Small fix to take care of <body background="whatever">.

graf25 23 years ago
parent
commit
8d3cd32104
1 changed files with 25 additions and 23 deletions
  1. 25 23
      functions/mime.php

+ 25 - 23
functions/mime.php

@@ -1170,8 +1170,6 @@ function sq_skipspace($body, $offset){
     if (sizeof($matches{1})){
     if (sizeof($matches{1})){
         $count = strlen($matches{1});
         $count = strlen($matches{1});
         $offset += $count;
         $offset += $count;
-        //if ($pos >= strlen($body)){
-        //}
     }
     }
     return $offset;
     return $offset;
 }
 }
@@ -1372,18 +1370,16 @@ function sq_getnxtag($body, $offset){
          */
          */
         $matches = Array();
         $matches = Array();
         if (preg_match("%^(\s*)(>|/>)%s", substr($body, $pos), $matches)) {
         if (preg_match("%^(\s*)(>|/>)%s", substr($body, $pos), $matches)) {
-           if ($matches{0}){
-               /**
-                * Yep. So we did.
-                */
-               $pos += strlen($matches{1});
-               if ($matches{2} == "/>"){
-                   $tagtype = 3;
-                   $pos++;
-               }
-               return Array($tagname, $attary, $tagtype, $lt, $pos);
-           }
-	}
+            /**
+             * Yep. So we did.
+             */
+            $pos += strlen($matches{1});
+            if ($matches{2} == "/>"){
+                $tagtype = 3;
+                $pos++;
+            }
+            return Array($tagname, $attary, $tagtype, $lt, $pos);
+        }
 
 
         /**
         /**
          * There are several types of attributes, with optional
          * There are several types of attributes, with optional
@@ -1815,11 +1811,6 @@ function sq_sanitize($body,
              * content before we apply it.
              * content before we apply it.
              */
              */
             $free_content = sq_fixstyle($message, $id, $free_content);
             $free_content = sq_fixstyle($message, $id, $free_content);
-        } else if ($tagname == "body"){
-            $tagname = "div";
-            if ($tagtype == 1){
-                $attary = sq_body2div($attary);
-            }
         }
         }
         if ($skip_content == false){
         if ($skip_content == false){
             $trusted .= $free_content;
             $trusted .= $free_content;
@@ -1835,11 +1826,15 @@ function sq_sanitize($body,
                     $skip_content = false;
                     $skip_content = false;
                 } else {
                 } else {
                     if ($skip_content == false){
                     if ($skip_content == false){
-                        if (isset($open_tags{$tagname}) && 
-                            $open_tags{$tagname} > 0){
-                            $open_tags{$tagname}--;
+                        if ($tagname == "body"){
+                            $tagname = "div";
                         } else {
                         } else {
-                            $tagname = false;
+                            if (isset($open_tags{$tagname}) && 
+                                $open_tags{$tagname} > 0){
+                                $open_tags{$tagname}--;
+                            } else {
+                                $tagname = false;
+                            }
                         }
                         }
                     } else {
                     } else {
                     }
                     }
@@ -1891,6 +1886,13 @@ function sq_sanitize($body,
                                                      $id
                                                      $id
                                                      );
                                                      );
                             }
                             }
+                            /**
+                             * Convert body into div.
+                             */
+                            if ($tagname == "body"){
+                                $tagname = "div";
+                                $attary = sq_body2div($attary, $message, $id);
+                            }
                         }
                         }
                     }
                     }
                 } else {
                 } else {