From 7ac94421bf85eb04c00c5ed05390e1ea0c6bcb0b Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 25 Dec 2012 18:06:17 +0100 Subject: Move washtml class into Roundcube Framework (rcube_washtml), add some improvements --- program/steps/mail/func.inc | 68 +-------------------------------------------- 1 file changed, 1 insertion(+), 67 deletions(-) (limited to 'program/steps/mail/func.inc') diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 70493766b..90f54cf1b 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -628,39 +628,6 @@ function rcmail_wash_html($html, $p, $cid_replaces) $p += array('safe' => false, 'inline_html' => true); - // special replacements (not properly handled by washtml class) - $html_search = array( - '/(<\/nobr>)(\s+)()/i', // space(s) between - '/]*>[^<]*<\/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?) - '/]+>/i', // washtml/DOMDocument cannot handle xml namespaces - ); - $html_replace = array( - '\\1'.'   '.'\\3', - '', - '', - '', - ); - $html = preg_replace($html_search, $html_replace, trim($html)); - - // PCRE errors handling (#1486856), should we use something like for every preg_* use? - if ($html === null && ($preg_error = preg_last_error()) != PREG_NO_ERROR) { - $errstr = "Could not clean up HTML message! PCRE Error: $preg_error."; - - if ($preg_error == PREG_BACKTRACK_LIMIT_ERROR) - $errstr .= " Consider raising pcre.backtrack_limit!"; - if ($preg_error == PREG_RECURSION_LIMIT_ERROR) - $errstr .= " Consider raising pcre.recursion_limit!"; - - raise_error(array('code' => 620, 'type' => 'php', - 'line' => __LINE__, 'file' => __FILE__, - 'message' => $errstr), true, false); - return ''; - } - - // fix (unknown/malformed) HTML tags before "wash" - $html = preg_replace_callback('/(<[\/]*)([^\s>]+)/', 'rcmail_html_tag_callback', $html); - // charset was converted to UTF-8 in rcube_storage::get_message_part(), // change/add charset specification in HTML accordingly, // washtml cannot work without that @@ -674,9 +641,6 @@ function rcmail_wash_html($html, $p, $cid_replaces) $html = '' . $meta . '' . $html; } - // turn relative into absolute urls - $html = rcmail_resolve_base($html); - // clean HTML with washhtml by Frederic Motte $wash_opts = array( 'show_washed' => false, @@ -702,7 +666,7 @@ function rcmail_wash_html($html, $p, $cid_replaces) $wash_opts['html_attribs'] = $p['html_attribs']; // initialize HTML washer - $washer = new washtml($wash_opts); + $washer = new rcube_washtml($wash_opts); if (!$p['skip_washer_form_callback']) $washer->add_callback('form', 'rcmail_washtml_callback'); @@ -920,22 +884,6 @@ function rcmail_washtml_callback($tagname, $attrib, $content, $washtml) } -/** - * Callback function for HTML tags fixing - */ -function rcmail_html_tag_callback($matches) -{ - $tagname = $matches[2]; - - $tagname = preg_replace(array( - '/:.*$/', // Microsoft's Smart Tags - '/[^a-z0-9_\[\]\!-]/i', // forbidden characters - ), '', $tagname); - - return $matches[1].$tagname; -} - - /** * return table with message headers */ @@ -1319,20 +1267,6 @@ function rcmail_part_image_type($part) } } -/** - * Convert all relative URLs according to a in HTML - */ -function rcmail_resolve_base($body) -{ - // check for - if (preg_match('!(replace($body); - } - - return $body; -} - /** * modify a HTML message that it can be displayed inside a HTML page -- cgit v1.2.3