diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-07-28 12:22:04 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-07-28 12:22:04 +0000 |
| commit | 9a1a06e4cff0312053b3a05541261340885c6e2b (patch) | |
| tree | 4443c6751f8499d796ccd49faabf2a30733604ae | |
| parent | f3412820a98a1a7f57f01463c5a8ddc8a2bda288 (diff) | |
- Added handling of PCRE limits errors in rcmail_wash_html() (#1486856)
git-svn-id: https://svn.roundcube.net/trunk@3835 208e9e7b-5314-0410-a742-e7e81cd9613c
| -rw-r--r-- | roundcubemail/program/steps/mail/func.inc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/roundcubemail/program/steps/mail/func.inc b/roundcubemail/program/steps/mail/func.inc index 4603ad908..9d6d96dfb 100644 --- a/roundcubemail/program/steps/mail/func.inc +++ b/roundcubemail/program/steps/mail/func.inc @@ -626,6 +626,21 @@ function rcmail_wash_html($html, $p = array(), $cid_replaces) ); $html = preg_replace($html_search, $html_replace, $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' => 600, '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); |
