From cb4193da9f3d867fef61951d2df838f1ea1d3cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Sun, 9 Dec 2012 18:21:38 +0100 Subject: [PATCH] MDL-29442 add missing utf-8 to entity html encoding and decoding --- backup/util/loggers/file_logger.class.php | 2 +- backup/util/loggers/output_indented_logger.class.php | 2 +- backup/util/loggers/output_text_logger.class.php | 2 +- lib/datalib.php | 2 +- lib/dml/pdo_moodle_database.php | 2 +- lib/filelib.php | 2 +- lib/navigationlib.php | 6 +++--- mod/wiki/pagelib.php | 2 +- mod/wiki/parser/utils.php | 4 ++-- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/backup/util/loggers/file_logger.class.php b/backup/util/loggers/file_logger.class.php index e4ab4b1d824..5c05380d36f 100644 --- a/backup/util/loggers/file_logger.class.php +++ b/backup/util/loggers/file_logger.class.php @@ -75,7 +75,7 @@ class file_logger extends base_logger { if (substr($this->fullpath, -5) !== '.html') { $content = $prefix . str_repeat(' ', $depth) . $message . PHP_EOL; } else { - $content = $prefix . str_repeat('  ', $depth) . htmlentities($message, ENT_QUOTES) . '
' . PHP_EOL; + $content = $prefix . str_repeat('  ', $depth) . htmlentities($message, ENT_QUOTES, 'UTF-8') . '
' . PHP_EOL; } if (false === fwrite($this->fhandle, $content)) { throw new base_logger_exception('error_writing_file', $this->fullpath); diff --git a/backup/util/loggers/output_indented_logger.class.php b/backup/util/loggers/output_indented_logger.class.php index 8bb68113920..2eaea5b60a6 100644 --- a/backup/util/loggers/output_indented_logger.class.php +++ b/backup/util/loggers/output_indented_logger.class.php @@ -38,7 +38,7 @@ class output_indented_logger extends base_logger { if (defined('STDOUT')) { echo $prefix . str_repeat(' ', $depth) . $message . PHP_EOL; } else { - echo $prefix . str_repeat('  ', $depth) . htmlentities($message, ENT_QUOTES) . '
' . PHP_EOL; + echo $prefix . str_repeat('  ', $depth) . htmlentities($message, ENT_QUOTES, 'UTF-8') . '
' . PHP_EOL; } flush(); return true; diff --git a/backup/util/loggers/output_text_logger.class.php b/backup/util/loggers/output_text_logger.class.php index fe61536c039..9d13dfdc63e 100644 --- a/backup/util/loggers/output_text_logger.class.php +++ b/backup/util/loggers/output_text_logger.class.php @@ -37,7 +37,7 @@ class output_text_logger extends base_logger { if (defined('STDOUT')) { echo $prefix . $message . PHP_EOL; } else { - echo $prefix . htmlentities($message, ENT_QUOTES) . '
' . PHP_EOL; + echo $prefix . htmlentities($message, ENT_QUOTES, 'UTF-8') . '
' . PHP_EOL; } flush(); return true; diff --git a/lib/datalib.php b/lib/datalib.php index 526b16e4ffa..bb103e3d22b 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -1694,7 +1694,7 @@ function add_to_log($courseid, $module, $action, $url='', $info='', $cm=0, $user $timenow = time(); $info = $info; if (!empty($url)) { // could break doing html_entity_decode on an empty var. - $url = html_entity_decode($url); + $url = html_entity_decode($url, ENT_QUOTES, 'UTF-8'); } else { $url = ''; } diff --git a/lib/dml/pdo_moodle_database.php b/lib/dml/pdo_moodle_database.php index 111655f19d0..631776aee29 100644 --- a/lib/dml/pdo_moodle_database.php +++ b/lib/dml/pdo_moodle_database.php @@ -171,7 +171,7 @@ abstract class pdo_moodle_database extends moodle_database { * Function to print/save/ignore debugging messages related to SQL queries. */ protected function debug_query($sql, $params = null) { - echo '
(', $this->get_dbtype(), '): ', htmlentities($sql); + echo '
(', $this->get_dbtype(), '): ', htmlentities($sql, ENT_QUOTES, 'UTF-8'); if($params) { echo ' (parameters '; print_r($params); diff --git a/lib/filelib.php b/lib/filelib.php index d7d9b4959ae..fe812d83b81 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -1892,7 +1892,7 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss $options = new stdClass(); $options->newlines = false; $options->noclean = true; - $text = htmlentities($pathisstring ? $path : implode('', file($path))); + $text = htmlentities($pathisstring ? $path : implode('', file($path)), ENT_QUOTES, 'UTF-8'); $output = '
'. format_text($text, FORMAT_MOODLE, $options, $COURSE->id) .'
'; header('Content-Length: '.strlen($output)); diff --git a/lib/navigationlib.php b/lib/navigationlib.php index dae77d32c04..7ee14b41169 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -3138,9 +3138,9 @@ class settings_navigation extends navigation_node { continue; } if ($type->modclass == MOD_CLASS_RESOURCE) { - $resources[html_entity_decode($type->type)] = $type->typestr; + $resources[html_entity_decode($type->type, ENT_QUOTES, 'UTF-8')] = $type->typestr; } else { - $activities[html_entity_decode($type->type)] = $type->typestr; + $activities[html_entity_decode($type->type, ENT_QUOTES, 'UTF-8')] = $type->typestr; } } } else { @@ -4070,7 +4070,7 @@ class navigation_json { } if ($child->forcetitle || $child->title !== $child->text) { - $attributes['title'] = htmlentities($child->title); + $attributes['title'] = htmlentities($child->title, ENT_QUOTES, 'UTF-8'); } if (array_key_exists($child->key.':'.$child->type, $this->expandable)) { $attributes['expandable'] = $child->key; diff --git a/mod/wiki/pagelib.php b/mod/wiki/pagelib.php index 71fccff28f8..eda9e61cede 100644 --- a/mod/wiki/pagelib.php +++ b/mod/wiki/pagelib.php @@ -657,7 +657,7 @@ class page_wiki_comments extends page_wiki { $parsedcontent = wiki_parse_content('nwiki', $comment->content, $options); } - $cell4->text = format_text(html_entity_decode($parsedcontent['parsed_text']), FORMAT_HTML); + $cell4->text = format_text(html_entity_decode($parsedcontent['parsed_text'], ENT_QUOTES, 'UTF-8'), FORMAT_HTML); } else { $cell4->text = format_text($comment->content, FORMAT_HTML); } diff --git a/mod/wiki/parser/utils.php b/mod/wiki/parser/utils.php index eb14bc07657..f777f28058d 100644 --- a/mod/wiki/parser/utils.php +++ b/mod/wiki/parser/utils.php @@ -14,9 +14,9 @@ require_once($CFG->dirroot . "/lib/outputcomponents.php"); class parser_utils { public static function h($tag, $text = null, $options = array(), $escape_text = false) { - $tag = htmlentities($tag); + $tag = htmlentities($tag, ENT_COMPAT, 'UTF-8'); if(!empty($text) && $escape_text) { - $text = htmlentities($text); + $text = htmlentities($text, ENT_COMPAT, 'UTF-8'); } return html_writer::tag($tag, $text, $options); }