Skip to content

Commit

Permalink
Fixed issue #6916: HTML not properly saved when editing an assessment…
Browse files Browse the repository at this point in the history
… rule
  • Loading branch information
c-schmitz committed Nov 23, 2012
1 parent e850e3c commit 5a25a2a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
5 changes: 0 additions & 5 deletions application/controllers/admin/assessments.php
Expand Up @@ -197,11 +197,6 @@ private function _getAssessmentPostData($iSurveyID, $language)
if (!isset($_POST['gid']))
$_POST['gid'] = 0;

if (Yii::app()->getConfig('filterxsshtml')) {
$_POST['name_' . $language] = htmlspecialchars($_POST['name_' . $language]);
$_POST['assessmentmessage_' . $language] = htmlspecialchars($_POST['assessmentmessage_' . $language]);
}

return array(
'sid' => $iSurveyID,
'scope' => sanitize_paranoid_string($_POST['scope']),
Expand Down
27 changes: 27 additions & 0 deletions application/models/Assessment.php
Expand Up @@ -29,6 +29,33 @@ public static function model($class = __CLASS__)
return parent::model($class);
}

public function rules()
{
return array(
array('name', 'xssfilter'),
array('message', 'xssfilter')
);
}

/**
* Defines the customs validation rule xssfilter
*
* @param mixed $attribute
* @param mixed $params
*/
public function xssfilter($attribute,$params)
{
if(Yii::app()->getConfig('filterxsshtml') && Yii::app()->session['USER_RIGHT_SUPERADMIN'] != 1)
{
$filter = new CHtmlPurifier();
$filter->options = array('URI.AllowedSchemes'=>array(
'http' => true,
'https' => true,
));
$this->$attribute = $filter->purify($this->$attribute);
}
}

/**
* Returns the setting's table name to be used by the model
*
Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/assessments_view.php
Expand Up @@ -70,7 +70,7 @@
<select name='gid' id='gid'>
<?php
foreach ($groups as $groupId => $groupName) {
echo '<option value="' . $groupId . '"'.($editId == $groupId ? ' selected' : '').'>' . $groupName . '</option>';
echo '<option value="' . $groupId . '"'.(isset($editdata['gid']) && $editdata['gid']== $groupId ? ' selected' : '').'>' . $groupName . '</option>';
}
?>
</select>
Expand Down

2 comments on commit 5a25a2a

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Carsten : i put this one b379b4f after.

use LSYii_Validators .

Think i move this one : http://bugs.limesurvey.org/view.php?id=6888 for 2.0 too :)

@c-schmitz
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I saw - thank you!

Please sign in to comment.