From e2f90dbd4e25c9c95764c30126ad7d2a1ec213c0 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Wed, 16 Oct 2013 03:35:36 -0400
Subject: [PATCH] Do not add css files to the page when body is empty, e.g. upload iframes

---
 program/include/rcmail_output_html.php |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php
index 7cab372..6651a94 100644
--- a/program/include/rcmail_output_html.php
+++ b/program/include/rcmail_output_html.php
@@ -1280,7 +1280,12 @@
      */
     public function _write($templ = '', $base_path = '')
     {
-        $output = empty($templ) ? $this->default_template : trim($templ);
+        $output = trim($templ);
+
+        if (empty($output)) {
+            $output   = $this->default_template;
+            $is_empty = true;
+        }
 
         // set default page title
         if (empty($this->pagetitle)) {
@@ -1371,8 +1376,8 @@
         }
 
         // add css files in head, before scripts, for speed up with parallel downloads
-        if (!empty($this->css_files) && 
-            (($pos = stripos($output, '<script ')) || ($pos = stripos($output, '</head>')))
+        if (!empty($this->css_files) && !$is_empty
+            && (($pos = stripos($output, '<script ')) || ($pos = stripos($output, '</head>')))
         ) {
             $css = '';
             foreach ($this->css_files as $file) {

--
Gitblit v1.9.1