Skip to content

Commit e29bb97

Browse files
marinaglancyDamyon Wiese
authored and
Damyon Wiese
committed
MDL-45616 repositories: API changes to avoid serialized data in user input
1 parent 56964b7 commit e29bb97

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

Diff for: repository/lib.php

-8
Original file line numberDiff line numberDiff line change
@@ -1671,14 +1671,6 @@ public static function display_instances_list($context, $typename = null) {
16711671
public function get_file_reference($source) {
16721672
if ($source && $this->has_moodle_files()) {
16731673
$params = @json_decode(base64_decode($source), true);
1674-
if (!$params && !in_array($this->get_typename(), array('recent', 'user', 'local', 'coursefiles'))) {
1675-
// IMPORTANT! Since default format for moodle files was changed in the minor release as a security fix
1676-
// we maintain an old code here in order not to break 3rd party repositories that deal
1677-
// with moodle files. Repositories are strongly encouraged to be upgraded, see MDL-45616.
1678-
// In Moodle 2.8 this fallback will be removed.
1679-
$params = file_storage::unpack_reference($source, true);
1680-
return file_storage::pack_reference($params);
1681-
}
16821674
if (!is_array($params) || empty($params['contextid'])) {
16831675
throw new repository_exception('invalidparams', 'repository');
16841676
}

Diff for: repository/upgrade.txt

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ information provided here is intended especially for developers. Full
33
details of the repository API are available on Moodle docs:
44
http://docs.moodle.org/dev/Repository_API
55

6+
=== 2.8 ===
7+
8+
* Repositories working with Moodle files must replace serialize() with json_encode() in the
9+
attribute 'source' returned by get_listing(). If repository overrides file_is_accessible(),
10+
get_file_reference() or get_file_source_info() they need to be changed too. See MDL-45616.
11+
612
=== 2.6 ===
713

814
* get_option() now always return null when the first parameter ($config) is not empty, and

0 commit comments

Comments
 (0)