From 2965a981b7ec22866fbdf2d567d87e2d068d3617 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Fri, 31 Jul 2015 16:04:08 -0400
Subject: [PATCH] Allow to search and import missing PGP pubkeys from keyservers using Publickey.js

---
 program/lib/Roundcube/rcube_washtml.php |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/program/lib/Roundcube/rcube_washtml.php b/program/lib/Roundcube/rcube_washtml.php
index 4bf189e..b042f5f 100644
--- a/program/lib/Roundcube/rcube_washtml.php
+++ b/program/lib/Roundcube/rcube_washtml.php
@@ -244,8 +244,8 @@
                 $t .= ' ' . $key . '="' . htmlspecialchars($value, ENT_QUOTES) . '"';
             }
             else if ($key == 'style' && ($style = $this->wash_style($value))) {
-                $quot = strpos($style, '"') !== false ? "'" : '"';
-                $t .= ' style=' . $quot . $style . $quot;
+                // replace double quotes to prevent syntax error and XSS issues (#1490227)
+                $t .= ' style="' . str_replace('"', '&quot;', $style) . '"';
             }
             else if ($key == 'background'
                 || ($key == 'src' && preg_match('/^(img|source)$/i', $node->tagName))
@@ -403,16 +403,23 @@
     {
         // special replacements (not properly handled by washtml class)
         $html_search = array(
-            '/(<\/nobr>)(\s+)(<nobr>)/i',       // space(s) between <NOBR>
-            '/<title[^>]*>[^<]*<\/title>/i',    // PHP bug #32547 workaround: remove title tag
-            '/^(\0\0\xFE\xFF|\xFF\xFE\0\0|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/',    // byte-order mark (only outlook?)
-            '/<html\s[^>]+>/i',                 // washtml/DOMDocument cannot handle xml namespaces
+            // space(s) between <NOBR>
+            '/(<\/nobr>)(\s+)(<nobr>)/i',
+            // PHP bug #32547 workaround: remove title tag
+            '/<title[^>]*>[^<]*<\/title>/i',
+            // remove <!doctype> before BOM (#1490291)
+            '/<\!doctype[^>]+>[^<]*/im',
+            // byte-order mark (only outlook?)
+            '/^(\0\0\xFE\xFF|\xFF\xFE\0\0|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/',
+            // washtml/DOMDocument cannot handle xml namespaces
+            '/<html\s[^>]+>/i',
         );
 
         $html_replace = array(
             '\\1'.' &nbsp; '.'\\3',
             '',
             '',
+            '',
             '<html>',
         );
         $html = preg_replace($html_search, $html_replace, trim($html));

--
Gitblit v1.9.1