Remove remove_xss and stripslashes while saving. see #1433

pull/2487/head
jmontoyaa 9 years ago
parent ef680c5ac3
commit 7d5284d51b
  1. 28
      main/inc/introductionSection.inc.php

@ -1,6 +1,8 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CourseBundle\Entity\CToolIntro;
/** /**
* The INTRODUCTION MICRO MODULE is used to insert and edit * The INTRODUCTION MICRO MODULE is used to insert and edit
* an introduction section on a Chamilo module or on the course homepage. * an introduction section on a Chamilo module or on the course homepage.
@ -28,8 +30,6 @@
* @package chamilo.include * @package chamilo.include
*/ */
use Chamilo\CourseBundle\Entity\CToolIntro;
$TBL_INTRODUCTION = Database::get_course_table(TABLE_TOOL_INTRO); $TBL_INTRODUCTION = Database::get_course_table(TABLE_TOOL_INTRO);
$intro_editAllowed = $is_allowed_to_edit; $intro_editAllowed = $is_allowed_to_edit;
$session_id = api_get_session_id(); $session_id = api_get_session_id();
@ -70,12 +70,7 @@ if ($intro_editAllowed) {
if ($intro_cmdUpdate) { if ($intro_cmdUpdate) {
if ($form->validate()) { if ($form->validate()) {
$form_values = $form->exportValues(); $form_values = $form->exportValues();
$intro_content = Security::remove_XSS( $intro_content = $form_values['intro_content'];
stripslashes(
api_html_entity_decode($form_values['intro_content'])
),
COURSEMANAGERLOWSECURITY
);
$criteria = [ $criteria = [
'cId' => $course_id, 'cId' => $course_id,
@ -90,8 +85,7 @@ if ($intro_editAllowed) {
->findOneBy($criteria); ->findOneBy($criteria);
if ($toolIntro) { if ($toolIntro) {
$toolIntro $toolIntro->setIntroText($intro_content);
->setIntroText($intro_content);
} else { } else {
$toolIntro = new CToolIntro(); $toolIntro = new CToolIntro();
$toolIntro $toolIntro
@ -103,10 +97,12 @@ if ($intro_editAllowed) {
Database::getManager()->persist($toolIntro); Database::getManager()->persist($toolIntro);
Database::getManager()->flush(); Database::getManager()->flush();
$introduction_section .= Display::return_message( Display::addFlash(
Display::return_message(
get_lang('IntroductionTextUpdated'), get_lang('IntroductionTextUpdated'),
'confirmation', 'confirmation',
false false
)
); );
} else { } else {
// got to the delete command // got to the delete command
@ -125,7 +121,9 @@ if ($intro_editAllowed) {
id='".Database::escape_string($moduleId)."' AND id='".Database::escape_string($moduleId)."' AND
session_id='".intval($session_id)."'"; session_id='".intval($session_id)."'";
Database::query($sql); Database::query($sql);
$introduction_section .= Display::return_message(get_lang('IntroductionTextDeleted'), 'confirmation'); Display::addFlash(
Display::return_message(get_lang('IntroductionTextDeleted'), 'confirmation')
);
} }
} }
@ -134,7 +132,7 @@ if ($intro_editAllowed) {
/* Retrieves the module introduction text, if exist */ /* Retrieves the module introduction text, if exist */
/* @todo use a lib to query the $TBL_INTRODUCTION table */ /* @todo use a lib to query the $TBL_INTRODUCTION table */
// Getting course intro // Getting course intro
$intro_content = null; $intro_content = '';
$sql = "SELECT intro_text FROM $TBL_INTRODUCTION $sql = "SELECT intro_text FROM $TBL_INTRODUCTION
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
@ -155,7 +153,7 @@ if (!empty($session_id)) {
id = '".Database::escape_string($moduleId)."' AND id = '".Database::escape_string($moduleId)."' AND
session_id = '".intval($session_id)."'"; session_id = '".intval($session_id)."'";
$intro_dbQuery = Database::query($sql); $intro_dbQuery = Database::query($sql);
$introSessionContent = null; $introSessionContent = '';
if (Database::num_rows($intro_dbQuery) > 0) { if (Database::num_rows($intro_dbQuery) > 0) {
$intro_dbResult = Database::fetch_array($intro_dbQuery); $intro_dbResult = Database::fetch_array($intro_dbQuery);
$introSessionContent = $intro_dbResult['intro_text']; $introSessionContent = $intro_dbResult['intro_text'];
@ -166,6 +164,8 @@ if (!empty($session_id)) {
} }
} }
$intro_content = Security::remove_XSS($intro_content);
/* Determines the correct display */ /* Determines the correct display */
if ($intro_cmdEdit || $intro_cmdAdd) { if ($intro_cmdEdit || $intro_cmdAdd) {

Loading…
Cancel
Save