Skip to content

Commit

Permalink
MDL-33430 Make file_storage::unpack_reference() more picky on what it…
Browse files Browse the repository at this point in the history
… gets
  • Loading branch information
mudrd8mz committed Jun 20, 2012
1 parent f4a9bf6 commit 6feae1d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/filestorage/file_storage.php
Expand Up @@ -1659,7 +1659,14 @@ public static function pack_reference($params) {
* @return array
*/
public static function unpack_reference($str, $cleanparams = false) {
$params = unserialize(base64_decode($str));
$decoded = base64_decode($str, true);
if ($decoded === false) {
throw new file_reference_exception(null, $str, null, null, 'Invalid base64 format');
}
$params = @unserialize($decoded); // hide E_NOTICE
if ($params === false) {
throw new file_reference_exception(null, $decoded, null, null, 'Not an unserializeable value');
}
if (is_array($params) && $cleanparams) {
$params = array(
'component' => is_null($params['component']) ? '' : clean_param($params['component'], PARAM_COMPONENT),
Expand Down

0 comments on commit 6feae1d

Please sign in to comment.