Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue : Unable to create survey with debug = 2 and PHP8 #3613

Merged
merged 2 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 18 additions & 2 deletions application/core/LSYii_Validators.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,15 @@ public function fixCKeditor($value)
/**
* Remove any script or dangerous HTML
*
* @param string $value
* @param null|string $value
* @return string
*/
public function xssFilter($value)
{
/* No need to filter empty $value */
if (empty($value)) {
return strval($value);
}
$filter = LSYii_HtmlPurifier::getXssPurifier();

/** Start to get complete filtered value with url decode {QCODE} (bug #09300). This allow only question number in url, seems OK with XSS protection **/
Expand Down Expand Up @@ -166,10 +170,14 @@ public function xssFilter($value)
* Defines the customs validation rule for language string
*
* @param mixed $value
* @return mixed
* @return string
*/
public function languageFilter($value)
{
/* No need to filter empty $value */
if (empty($value)) {
return strval($value);
}
// Maybe use the array of language ?
return preg_replace('/[^a-z0-9-]/i', '', (string) $value);
}
Expand All @@ -182,6 +190,10 @@ public function languageFilter($value)
*/
public function multiLanguageFilter($value)
{
/* No need to filter empty $value */
if (empty($value)) {
return strval($value);
}
$aValue = explode(" ", trim((string) $value));
$aValue = array_map("sanitize_languagecode", $aValue);
return implode(" ", $aValue);
Expand All @@ -194,6 +206,10 @@ public function multiLanguageFilter($value)
*/
public static function isXssUrl($url)
{
/* No need to filter empty $value */
if (empty($url)) {
return false;
}
$decodedUrl = self::treatSpecialChars($url);
$clean = self::removeInvisibleChars($decodedUrl);

Expand Down
3 changes: 3 additions & 0 deletions application/models/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,9 @@ public function permission($loginID)
*/
public function getAdditionalLanguages()
{
if (is_null($this->additional_languages)) {
return [];
}
$sLanguages = trim($this->additional_languages);
if ($sLanguages != '') {
return explode(' ', $sLanguages);
Expand Down