From b9ec2bd1b49450895e57be184b70d80c76a1e8f0 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Wed, 28 Jul 2010 08:22:04 -0400
Subject: [PATCH] - Added handling of PCRE limits errors in rcmail_wash_html() (#1486856)
---
program/steps/mail/func.inc | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 4603ad9..9d6d96d 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -626,6 +626,21 @@
);
$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);
--
Gitblit v1.9.1