Skip to content

Commit

Permalink
Fixed issue [security] #15720: Reflected Cross-Site Scripting in posi…
Browse files Browse the repository at this point in the history
…tion widget (Maxime Roy)
  • Loading branch information
olleharstedt committed Jan 21, 2020
1 parent 1db3247 commit d8f84b4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion application/controllers/admin/questions.php
Expand Up @@ -1284,7 +1284,8 @@ public function ajaxReloadPositionWidget($gid, $classes = '')

);

if ($classes != '') {
// TODO: Better solution: Hard-code allowed CSS classes.
if ($classes != '' && $this->isValidCSSClass($classes)) {
$aOptions['classes'] = $classes;
}

Expand Down Expand Up @@ -1540,6 +1541,18 @@ public function ajaxGetQuestionTemplateList()
Yii::app()->end();
}

/**
* Returns true if $class is a valid CSS class (alphanumeric + '-' and '_')
*
* @param string $class
* @return boolean
*/
protected function isValidCSSClass($class)
{
$class = str_replace(['-', '_'], '', $class);
return ctype_alnum($class);
}

/**
* Renders template(s) wrapped in header and footer
*
Expand Down

0 comments on commit d8f84b4

Please sign in to comment.