Add Horde_Domhtml::getHead()
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 7 Jan 2011 20:05:27 +0000 (13:05 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 12 Jan 2011 06:56:33 +0000 (23:56 -0700)
framework/Text_Filter/lib/Horde/Text/Filter/Xss.php
framework/Util/lib/Horde/Domhtml.php
imp/view.php

index d76535f..99c1afc 100644 (file)
@@ -109,14 +109,8 @@ class Horde_Text_Filter_Xss extends Horde_Text_Filter_Base
             $meta->setAttribute('http-equiv', 'x-dns-prefetch-control');
             $meta->setAttribute('value-equiv', 'off');
 
-            $head = $dom->dom->getElementsByTagName('head');
-            if ($head->length) {
-                $head->item(0)->appendChild($meta);
-            } else {
-                $headelt = $dom->dom->createElement('head');
-                $headelt->appendChild($meta);
-                $dom->dom->appendChild($headelt);
-            }
+            $head = $dom->getHead();
+            $head->appendChild($meta);
         }
 
         if ($this->_params['return_dom']) {
index a4c222b..81273e0 100644 (file)
@@ -87,6 +87,24 @@ class Horde_Domhtml
     }
 
     /**
+     * Returns the HEAD element, or creates one if it doesn't exist.
+     *
+     * @return DOMElement  HEAD element.
+     */
+    public function getHead()
+    {
+        $head = $this->dom->getElementsByTagName('head');
+        if ($head->length) {
+            return $head->item(0);
+        }
+
+        $headelt = $this->dom->createElement('head');
+        $this->dom->appendChild($headelt);
+
+        return $headelt;
+    }
+
+    /**
      * Returns the full HTML text in the original charset.
      *
      * @return string  HTML text.
index 62354b9..a66c2c4 100644 (file)
@@ -307,7 +307,7 @@ case 'print_attach':
                     $headers = $contents->getHeaderOb();
                     $imp_ui_mbox = new IMP_Ui_Mailbox();
 
-                    $headelt = $doc->dom->getElementsByTagName('head')->item(0);
+                    $headelt = $doc->getHead();
                     foreach ($headelt->getElementsByTagName('title') as $node) {
                         $headelt->removeChild($node);
                     }