From 26685f13a0989a5723d8128aaa83fdcfd896beda Mon Sep 17 00:00:00 2001 From: Adam Olley Date: Wed, 3 Feb 2016 22:28:44 +1030 Subject: [PATCH] MDL-52983 excel output: avoid single quote on end of sheet name This change resolves a problem where a long sheet name, which gets trimmed down with substr($name, 0, 31), could result in a sheet name with a single quote on the end because the quote removal was done before the substr. --- lib/excellib.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/excellib.class.php b/lib/excellib.class.php index b75f173a06e..ff382526cd8 100644 --- a/lib/excellib.class.php +++ b/lib/excellib.class.php @@ -163,6 +163,8 @@ class MoodleExcelWorksheet { $name = strtr(trim($name, "'"), '[]*/\?:', ' '); // Shorten the title if necessary. $name = core_text::substr($name, 0, 31); + // After the substr, we might now have a single quote on the end. + $name = trim($name, "'"); if ($name === '') { // Name is required!