Skip to content

Commit

Permalink
Merge branch 'MDL-76838' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jun 8, 2023
2 parents d1295a8 + 3bfb7f7 commit 7de0cb3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backup/util/xml/xml_writer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ protected function xml_safe_text_content($content) {
protected function xml_safe_utf8($content) {
$content = preg_replace('/[\x-\x8\xb-\xc\xe-\x1f\x7f]/is', '', $content ?? ''); // clean CTRL chars.
$content = preg_replace("/\r\n|\r/", "\n", $content); // Normalize line&return=>line
return $content;
return fix_utf8($content);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1318,8 +1318,9 @@ function fix_utf8($value) {
// Shortcut.
return $value;
}
// No null bytes expected in our data, so let's remove it.
$value = str_replace("\0", '', $value);

// Remove null bytes or invalid Unicode sequences from value.
$value = str_replace(["\0", "\xef\xbf\xbe", "\xef\xbf\xbf"], '', $value);

// Note: this duplicates min_fix_utf8() intentionally.
static $buggyiconv = null;
Expand Down

0 comments on commit 7de0cb3

Please sign in to comment.