From 119451832e74ede42a255dbca764b10eaba47a4b Mon Sep 17 00:00:00 2001 From: kenwest Date: Tue, 14 Aug 2018 21:58:18 +1000 Subject: [PATCH] The description of a JobLog entry is a summary of the message. Prior to this change the message was truncated, but this causes issues if the message included HTML tags. This change strips HTML tags from the message before truncation. The description is limited to 240 characters and has an ellipsis added if it is truncated. --- CRM/Core/JobManager.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/CRM/Core/JobManager.php b/CRM/Core/JobManager.php index fccfc18b8c..0583f9c255 100644 --- a/CRM/Core/JobManager.php +++ b/CRM/Core/JobManager.php @@ -229,10 +229,21 @@ class CRM_Core_JobManager { $dao = new CRM_Core_DAO_JobLog(); $dao->domain_id = $domainID; - $dao->description = substr($message, 0, 235); - if (strlen($message) > 235) { - $dao->description .= " (...)"; + + /* + * The description is a summary of the message. + * HTML tags are stripped from the message. + * The description is limited to 240 characters + * and has an ellipsis added if it is truncated. + */ + $maxDescription = 240; + $ellipsis = " (...)"; + $description = strip_tags($message); + if (strlen($description) > $maxDescription) { + $description = substr($description, 0, $maxDescription - strlen($ellipsis)) . $ellipsis; } + $dao->description = $description; + if ($this->currentJob) { $dao->job_id = $this->currentJob->id; $dao->name = $this->currentJob->name; -- 2.25.1