From 5af6c9676ebd86e390ef71089b210b6ad4dc3de3 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Mon, 18 Jun 2012 13:21:40 +0100 Subject: [PATCH] MDL-33780 question import: strip UTF8 BOM Previously, if there was a byte-order mark at the start of the file, the import would just break, which was silly. Much better to just strip it off. --- question/format.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/question/format.php b/question/format.php index 2e3e3e2d4d4..0ccdbce99e9 100644 --- a/question/format.php +++ b/question/format.php @@ -539,7 +539,10 @@ class qformat_default { if (is_readable($filename)) { $filearray = file($filename); - /// Check for Macintosh OS line returns (ie file on one line), and fix + // If the first line of the file starts with a UTF-8 BOM, remove it. + $filearray[0] = textlib::trim_utf8_bom($filearray[0]); + + // Check for Macintosh OS line returns (ie file on one line), and fix. if (preg_match("~\r~", $filearray[0]) AND !preg_match("~\n~", $filearray[0])) { return explode("\r", $filearray[0]); } else {