From 4a1ea1ad8571082f7dc0dfd32af79a237185fc1b Mon Sep 17 00:00:00 2001 From: Cindy Li Date: Fri, 15 Oct 2010 19:00:30 +0000 Subject: [PATCH] replace htmlentities() with htmlentities_utf8() --- docs/documentation/frame_content.php | 2 +- docs/documentation/frame_header.php | 2 +- .../classes/Weblinks/WeblinksExport.class.php | 2 +- docs/include/header.inc.php | 2 +- docs/include/vitals.inc.php | 16 ++++++++++++++++ docs/tests/html/tests_questions.inc.php | 4 ++-- docs/themes/default/home/course/content.tmpl.php | 8 ++++---- docs/themes/default/home/create_course.tmpl.php | 2 +- docs/themes/default/include/footer.tmpl.php | 2 +- docs/themes/default/include/header.tmpl.php | 2 +- 10 files changed, 29 insertions(+), 13 deletions(-) diff --git a/docs/documentation/frame_content.php b/docs/documentation/frame_content.php index e19799d..5ad675d 100644 --- a/docs/documentation/frame_content.php +++ b/docs/documentation/frame_content.php @@ -14,7 +14,7 @@ define('TR_INCLUDE_PATH', '../include/'); include(TR_INCLUDE_PATH.'vitals.inc.php'); if (isset($_GET['p'])) { - $this_page = htmlentities($_GET['p']); + $this_page = htmlentities_utf8($_GET['p']); } else { $this_page = 'index.php'; } diff --git a/docs/documentation/frame_header.php b/docs/documentation/frame_header.php index 3b54446..30d59bb 100644 --- a/docs/documentation/frame_header.php +++ b/docs/documentation/frame_header.php @@ -14,7 +14,7 @@ define('TR_INCLUDE_PATH', '../include/'); include(TR_INCLUDE_PATH.'vitals.inc.php'); if (isset($_GET['p'])) { - $this_page = htmlentities($_GET['p']); + $this_page = htmlentities_utf8($_GET['p']); } else { exit; } diff --git a/docs/include/classes/Weblinks/WeblinksExport.class.php b/docs/include/classes/Weblinks/WeblinksExport.class.php index 628adff..9899768 100644 --- a/docs/include/classes/Weblinks/WeblinksExport.class.php +++ b/docs/include/classes/Weblinks/WeblinksExport.class.php @@ -40,7 +40,7 @@ class WeblinksExport { $wl = $this->wl; //assign all the neccessarily values to the template. - $savant->assign('title', htmlentities($wl->getTitle(), ENT_QUOTES, 'UTF-8')); + $savant->assign('title', htmlentities_utf8($wl->getTitle(), ENT_QUOTES, 'UTF-8')); $url = $wl->getUrl(); $savant->assign('url_href', urlencode($url['href'])); $savant->assign('url_target', $url['target']); diff --git a/docs/include/header.inc.php b/docs/include/header.inc.php index 9d33dcb..165bcbe 100644 --- a/docs/include/header.inc.php +++ b/docs/include/header.inc.php @@ -129,7 +129,7 @@ if (isset($_custom_head)) { if (isset($_pages[$current_page]['guide'])) { $script_name = substr($_SERVER['PHP_SELF'], strlen($_base_path)); - $savant->assign('guide', TR_GUIDES_PATH .'index.php?p='. htmlentities($script_name)); + $savant->assign('guide', TR_GUIDES_PATH .'index.php?p='. htmlentities_utf8($script_name)); } $savant->assign('custom_css', $custom_css); diff --git a/docs/include/vitals.inc.php b/docs/include/vitals.inc.php index 2b422d2..85c9f39 100644 --- a/docs/include/vitals.inc.php +++ b/docs/include/vitals.inc.php @@ -400,6 +400,22 @@ function get_default_theme() { return $rows[0]['dir_name']; } +/** + * Convert all input to htmlentities output, in UTF-8. + * @param string input to be convert + * @param boolean true if we wish to change all newlines(\r\n) to a
tag, false otherwise. + * ref: http://php.net/manual/en/function.nl2br.php + * @author Harris Wong + * @date March 12, 2010 + */ +function htmlentities_utf8($str, $use_nl2br=true){ + $return = htmlentities($str, ENT_QUOTES, 'UTF-8'); + if ($use_nl2br){ + return nl2br($return); + } + return $return; +} + /** * Convert all '&' to '&' from the input * @param string any string input, mainly URLs. diff --git a/docs/tests/html/tests_questions.inc.php b/docs/tests/html/tests_questions.inc.php index 3f2d275..b0badc5 100644 --- a/docs/tests/html/tests_questions.inc.php +++ b/docs/tests/html/tests_questions.inc.php @@ -112,8 +112,8 @@ foreach ($cats as $cat) { echo ''; echo ''; echo ''; - echo ''; - echo AT_print(htmlentities(Utility::validateLength($row['question'], 100, 1), ENT_QUOTES, 'UTF-8'), 'tests_questions.question'); + echo ''; + echo AT_print(htmlentities_utf8(Utility::validateLength($row['question'], 100, 1), ENT_QUOTES, 'UTF-8'), 'tests_questions.question'); echo ''; echo ''; echo ''; diff --git a/docs/themes/default/home/course/content.tmpl.php b/docs/themes/default/home/course/content.tmpl.php index 47c864f..643f898 100644 --- a/docs/themes/default/home/course/content.tmpl.php +++ b/docs/themes/default/home/course/content.tmpl.php @@ -15,7 +15,7 @@ if (!defined('TR_INCLUDE_PATH')) { exit; } ?> has_text_alternative || $this->has_audio_alternative || $this->has_visual_alternative || $this->has_sign_lang_alternative): ?>
has_text_alternative) :?> - + <?php echo (($_GET['alternative'] == 3) ? _AT('stop_apply_text_alternatives') : _AT('apply_text_alternatives')); ?> has_audio_alternative) :?> - + <?php echo (($_GET['alternative'] == 1) ? _AT('stop_apply_audio_alternatives') : _AT('apply_audio_alternatives')); ?> has_visual_alternative) :?> - + <?php echo (($_GET['alternative'] == 4) ? _AT('stop_apply_visual_alternatives') : _AT('apply_visual_alternatives')); ?> has_sign_lang_alternative) :?> - + <?php echo (($_GET['alternative'] == 2) ? _AT('stop_apply_sign_lang_alternatives') : _AT('apply_sign_lang_alternatives')); ?>isAuthor())
-

+

diff --git a/docs/themes/default/include/footer.tmpl.php b/docs/themes/default/include/footer.tmpl.php index 48c71fa..e31f17a 100644 --- a/docs/themes/default/include/footer.tmpl.php +++ b/docs/themes/default/include/footer.tmpl.php @@ -59,7 +59,7 @@ if($languageManager->getNumEnabledLanguages() > 1) {
- course_copyright)) echo htmlentities($this->course_copyright, ENT_QUOTES, 'UTF-8').'
'; echo _AT("copyright"); ?>

+ course_copyright)) echo htmlentities_utf8($this->course_copyright, ENT_QUOTES, 'UTF-8').'
'; echo _AT("copyright"); ?>

diff --git a/docs/themes/default/include/header.tmpl.php b/docs/themes/default/include/header.tmpl.php index 931727a..7a201bc 100644 --- a/docs/themes/default/include/header.tmpl.php +++ b/docs/themes/default/include/header.tmpl.php @@ -162,7 +162,7 @@ foreach ($this->top_level_pages as $page) {
- + categories)) { // print category dropdown list box?>