]> git.wh0rd.org Git - tt-rss.git/commitdiff
sanitize: remove doctype properly, add experimental workaround against unnecessary...
authorAndrew Dolgov <fox@fakecake.org>
Sun, 6 Oct 2013 07:08:15 +0000 (11:08 +0400)
committerAndrew Dolgov <fox@fakecake.org>
Sun, 6 Oct 2013 07:08:15 +0000 (11:08 +0400)
include/functions.php

index e9b1270fb6eff60a994170bb919982b6da168493..c6ee6dfbdbeaa84134db28b0876ad0c230ef2dd7 100644 (file)
                        }
                }
 
-               $doc->removeChild($doc->firstChild); //remove doctype
+               $doc->removeChild($doc->doctype); //remove doctype
                $doc = strip_harmful_tags($doc, $allowed_elements, $disallowed_attributes);
 
                if ($highlight_words) {
                        }
                }
 
-               $res = $doc->saveHTML();
+               $body = $doc->getElementsByTagName("body")->item(0);
+
+               if ($body) {
+                       $div = $doc->createElement("div");
+
+                       foreach ($body->childNodes as $child) {
+                               $div->appendChild($child);
+                       }
+
+                       $res = $doc->saveXML($div);
+               } else {
+                       $res = $doc->saveHTML();
+               }
 
                return $res;
        }