CC-6055: Improved escaping
This commit is contained in:
parent
abc81a92b4
commit
b4c9a77e7c
10 changed files with 46 additions and 50 deletions
|
@ -46,13 +46,14 @@ class WidgetHelper
|
|||
);
|
||||
|
||||
$result[$dow[$i]] = $shows;
|
||||
|
||||
// XSS exploit prevention
|
||||
self::convertSpecialChars($result, array("name", "url"));
|
||||
// convert image paths to point to api endpoints
|
||||
self::findAndConvertPaths($result);
|
||||
}
|
||||
|
||||
// XSS exploit prevention
|
||||
SecurityHelper::htmlescape_recursive($result);
|
||||
|
||||
// convert image paths to point to api endpoints
|
||||
self::findAndConvertPaths($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -124,37 +125,18 @@ class WidgetHelper
|
|||
}
|
||||
$result[$weekCounter][$dayOfWeekCounter]["shows"] = $shows;
|
||||
|
||||
// XSS exploit prevention
|
||||
self::convertSpecialChars($result, array("name", "url"));
|
||||
// convert image paths to point to api endpoints
|
||||
self::findAndConvertPaths($result);
|
||||
|
||||
}
|
||||
$weekCounter += 1;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Go through a given array and sanitize any potentially exploitable fields
|
||||
* by passing them through htmlspecialchars
|
||||
*
|
||||
* @param unknown $arr the array to sanitize
|
||||
* @param unknown $keys indexes of values to be sanitized
|
||||
*/
|
||||
public static function convertSpecialChars(&$arr, $keys)
|
||||
{
|
||||
foreach ($arr as &$a) {
|
||||
if (is_array($a)) {
|
||||
foreach ($keys as &$key) {
|
||||
if (array_key_exists($key, $a)) {
|
||||
$a[$key] = htmlspecialchars($a[$key]);
|
||||
}
|
||||
}
|
||||
self::convertSpecialChars($a, $keys);
|
||||
}
|
||||
}
|
||||
// XSS exploit prevention
|
||||
SecurityHelper::htmlescape_recursive($result);
|
||||
|
||||
// convert image paths to point to api endpoints
|
||||
self::findAndConvertPaths($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue