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.
This commit is contained in:
Adam Olley 2016-02-03 22:28:44 +10:30
parent 9d5d9c64ff
commit 15c9a9d726

View File

@ -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!