From 5aece37dacdc232414e44a511bfe4bcf87e61139 Mon Sep 17 00:00:00 2001 From: Sean Madsen Date: Thu, 15 Mar 2018 10:58:33 -0400 Subject: [PATCH] CRM-21264 - Fix broken regular expression * Escape dot in token since it will be used in a regex (for good measure) * Add `(?![\w-])` to ensure that `td` is not followed by other characters that would make it a different element. * Instead of the first `.+?`, use `((?!).)*` which matches zero or more characters but refuses to consume if it encounters `` * Escape curly braces (for good measure) * Instead of the second `.+?`, use `.*?` so that it will match if there are zero characters. (Note: this change is really the crux of the issue, as described in CRM-21264). * Complete then closing `` (for good measure) --- CRM/Contribute/Form/Task/PDFLetterCommon.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/Form/Task/PDFLetterCommon.php b/CRM/Contribute/Form/Task/PDFLetterCommon.php index 321ef46086..f5fdb968c9 100644 --- a/CRM/Contribute/Form/Task/PDFLetterCommon.php +++ b/CRM/Contribute/Form/Task/PDFLetterCommon.php @@ -195,8 +195,8 @@ class CRM_Contribute_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDF * @return bool */ public static function isHtmlTokenInTableCell($token, $entity, $textToSearch) { - $tokenToMatch = $entity . '.' . $token; - $pattern = '||si'; $within = preg_match_all($pattern, $textToSearch); $total = preg_match_all("|{" . $tokenToMatch . "}|", $textToSearch); return ($within == $total); -- 2.25.1