Skip to content

Commit

Permalink
Merge pull request #100 from pantheon-systems/fix_utils_typo
Browse files Browse the repository at this point in the history
[BUGS-2865] Fix misspelled Class
  • Loading branch information
TeslaDethray authored Nov 7, 2019
2 parents 97358e7 + ec9ebfb commit e807851
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion php/pantheon/checks/sessions.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function run($file) {
$regex = '.*(session_start|\$_SESSION).*';
preg_match('#'.$regex.'#s',$file->getContents(), $matches, PREG_OFFSET_CAPTURE );
if ( $matches ) {
$matches = Util::sanitize_data($matches);
$matches = Utils::sanitize_data($matches);
$note = '';
if (count($matches) > 1) {
array_shift($matches);
Expand Down
10 changes: 6 additions & 4 deletions php/pantheon/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,22 @@ public static function load_fs() {
return self::$fs;
}

/**
/**
* Sanitizes data and keys recursively
*
* @param array|object|string $data
* @param mixed $data Data to be sanitized
* @param string|function $sanitizer_function Name of or the actual function with which to sanitize data
* @return array|object|string
*/
public static function sanitize_data($data) {
$sanitizer_function = 'htmlspecialchars';
public static function sanitize_data($data, $sanitizer_function = 'htmlspecialchars') {
if ( is_array( $data ) || is_object( $data ) ) {
$sanitized_data = array_combine(
array_map($sanitizer_function, array_keys((array)$data)),
array_map('self::sanitize_data', array_values((array)$data))
);
return is_object( $data ) ? (object)$sanitized_data : $sanitized_data;
} elseif ( is_integer($data) ) {
return (string)$data;
}

return $sanitizer_function($data);
Expand Down

0 comments on commit e807851

Please sign in to comment.