Skip to content

Commit

Permalink
MDL-33780 question import: strip UTF8 BOM
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
timhunt committed Jun 26, 2012
1 parent a5f6ea2 commit 5af6c96
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion question/format.php
Expand Up @@ -539,7 +539,10 @@ protected function readdata($filename) {
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 {
Expand Down

0 comments on commit 5af6c96

Please sign in to comment.