From 715c7961ba8ff72fe40720bb4feaa7865e57e8b9 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Tue, 01 Mar 2011 16:22:52 -0500
Subject: [PATCH] Don't do exact matches when searching for existing email records
---
program/lib/washtml.php | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/program/lib/washtml.php b/program/lib/washtml.php
index 923c97e..0f8dc7e 100644
--- a/program/lib/washtml.php
+++ b/program/lib/washtml.php
@@ -75,6 +75,7 @@
* - changed $ignore_elements behaviour
* - added RFC2397 support
* - base URL support
+ * - invalid HTML comments removal before parsing
*/
class washtml
@@ -89,7 +90,7 @@
static $html_attribs = array('name', 'class', 'title', 'alt', 'width', 'height', 'align', 'nowrap', 'col', 'row', 'id', 'rowspan', 'colspan', 'cellspacing', 'cellpadding', 'valign', 'bgcolor', 'color', 'border', 'bordercolorlight', 'bordercolordark', 'face', 'marginwidth', 'marginheight', 'axis', 'border', 'abbr', 'char', 'charoff', 'clear', 'compact', 'coords', 'vspace', 'hspace', 'cellborder', 'size', 'lang', 'dir');
/* Block elements which could be empty but cannot be returned in short form (<tag />) */
- static $block_elements = array('div', 'p', 'pre', 'blockquote', 'a', 'font');
+ static $block_elements = array('div', 'p', 'pre', 'blockquote', 'a', 'font', 'center', 'table', 'ul', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'dl', 'strong', 'i', 'b');
/* State for linked objects in HTML */
public $extlinks = false;
@@ -155,10 +156,11 @@
else
$this->extlinks = true;
}
- else if (preg_match('/^data:.+/i', $url)) { // RFC2397
- $value .= ' url('.htmlspecialchars($url, ENT_QUOTES).')';
+ else if (preg_match('/^data:.+/i', $match[2])) { // RFC2397
+ $value .= ' url('.htmlspecialchars($match[2], ENT_QUOTES).')';
}
- } else if ($match[0] != 'url' && $match[0] != 'rbg') //whitelist ?
+ }
+ else if ($match[0] != 'url' && $match[0] != 'rbg') //whitelist ?
$value .= ' ' . $match[0];
$str = substr($str, strlen($match[0]));
}
@@ -225,7 +227,9 @@
else if (isset($this->_html_elements[$tagName])) {
$content = $this->dumpHtml($node);
$dump .= '<' . $tagName . $this->wash_attribs($node) .
- ($content != '' || isset($this->_block_elements[$tagName]) ? ">$content</$tagName>" : ' />');
+ // create closing tag for block elements, but also for elements
+ // with content or with some attributes (eg. style, class) (#1486812)
+ ($content != '' || $node->hasAttributes() || isset($this->_block_elements[$tagName]) ? ">$content</$tagName>" : ' />');
}
else if (isset($this->_ignore_elements[$tagName])) {
$dump .= '<!-- ' . htmlspecialchars($tagName, ENT_QUOTES) . ' not allowed -->';
@@ -268,6 +272,9 @@
else
$this->config['base_url'] = '';
+ // Remove invalid HTML comments (#1487759)
+ $html = preg_replace('/<!--[^->]*>/', '', $html);
+
@$node->loadHTML($html);
return $this->dumpHtml($node);
}
--
Gitblit v1.9.1