Skip to content

Commit

Permalink
Merge branch 'MDL-72042-master' of git://github.com/sarjona/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyatregubov committed Sep 22, 2021
2 parents f4a730e + a0d3e32 commit 0e979b8
Show file tree
Hide file tree
Showing 23 changed files with 46 additions and 473 deletions.
4 changes: 2 additions & 2 deletions filter/mediaplugin/dev/perftest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

// Enable all players.
$enabledmediaplugins = \core\plugininfo\media::get_enabled_plugins();
\core\plugininfo\media::set_enabled_plugins('vimeo,youtube,videojs,html5audio,html5video,swf');
\core\plugininfo\media::set_enabled_plugins('vimeo,youtube,videojs,html5audio,html5video');

// Create plugin.
$filterplugin = new filter_mediaplugin(null, array());
Expand Down Expand Up @@ -153,4 +153,4 @@ function filter_mediaplugin_perf_stop($name) {

// End page.
echo html_writer::end_tag('ul');
print $OUTPUT->footer();
print $OUTPUT->footer();
4 changes: 2 additions & 2 deletions filter/mediaplugin/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function filter($text, array $options = array()) {
return $text;
}

// Check SWF permissions.
// Check permissions.
$this->trusted = !empty($options['noclean']) or !empty($CFG->allowobjectembed);

// Looking for tags.
Expand Down Expand Up @@ -177,7 +177,7 @@ private function callback(array $matches) {
*/
protected function embed_alternatives($urls, $name, $width, $height, $options) {

// Allow SWF (or not).
// Allow trusted content (or not).
if ($this->trusted) {
$options[core_media_manager::OPTION_TRUSTED] = true;
}
Expand Down
4 changes: 2 additions & 2 deletions filter/mediaplugin/tests/filter_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class filter_mediaplugin_testcase extends advanced_testcase {
function test_filter_mediaplugin_link() {
$this->resetAfterTest(true);

// we need to enable the plugins somehow and the flash fallback.
\core\plugininfo\media::set_enabled_plugins('vimeo,youtube,videojs,html5video,swf,html5audio');
// We need to enable the media plugins.
\core\plugininfo\media::set_enabled_plugins('vimeo,youtube,videojs,html5video,html5audio');
set_config('useflash', true, 'media_videojs');

$filterplugin = new filter_mediaplugin(null, array());
Expand Down
5 changes: 3 additions & 2 deletions lang/en/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -828,8 +828,6 @@
$string['mediapluginram'] = 'Enable .ram filter';
$string['mediapluginrm'] = 'Enable .rm filter';
$string['mediapluginrpm'] = 'Enable .rpm filter';
$string['mediapluginswf'] = 'Enable .swf filter';
$string['mediapluginswfnote'] = 'As a default security measure, normal users should not be allowed to embed swf flash files.';
$string['mediapluginwmv'] = 'Enable .wmv filter';
$string['mediapluginyoutube'] = 'Enable YouTube links filter';
$string['messaging'] = 'Enable messaging system';
Expand Down Expand Up @@ -1554,3 +1552,6 @@

// Deprecated since Moodle 4.0.
$string['coursepage'] = 'Course page';
$string['mediapluginswf'] = 'Enable .swf filter';
$string['mediapluginswfnote'] = 'As a default security measure, normal users should not be allowed to embed swf flash files.';

2 changes: 2 additions & 0 deletions lang/en/deprecated.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,5 @@ importfrominstructions,core_calendar
proceedtocourse,core_enrol
coursepage,core_admin
invalidpersistenterror,core_competency
mediapluginswf,core_admin
mediapluginswfnote,core_admin
2 changes: 0 additions & 2 deletions lib/classes/check/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public static function get_security_checks(): array {
new environment\publicpaths(),
new environment\configrw(),
new environment\preventexecpath(),
new security\mediafilterswf(),
new security\embed(),
new security\openprofiles(),
new security\crawlers(),
Expand Down Expand Up @@ -156,4 +155,3 @@ public static function get_security_checks(): array {
return $checks;
}
}

83 changes: 0 additions & 83 deletions lib/classes/check/security/mediafilterswf.php

This file was deleted.

4 changes: 2 additions & 2 deletions lib/classes/filetypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ protected static function get_default_types() {
'svgz' => array('type' => 'image/svg+xml', 'icon' => 'image',
'groups' => array('image', 'web_image'), 'string' => 'image'),
'swa' => array('type' => 'application/x-director', 'icon' => 'flash'),
'swf' => array('type' => 'application/x-shockwave-flash', 'icon' => 'flash', 'groups' => array('video', 'web_video')),
'swfl' => array('type' => 'application/x-shockwave-flash', 'icon' => 'flash', 'groups' => array('video', 'web_video')),
'swf' => array('type' => 'application/x-shockwave-flash', 'icon' => 'flash'),
'swfl' => array('type' => 'application/x-shockwave-flash', 'icon' => 'flash'),

'sxw' => array('type' => 'application/vnd.sun.xml.writer', 'icon' => 'writer'),
'stw' => array('type' => 'application/vnd.sun.xml.writer.template', 'icon' => 'writer'),
Expand Down
3 changes: 2 additions & 1 deletion lib/classes/plugin_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,7 @@ public static function is_deleted_standard_plugin($type, $name) {
'cachestore' => array('memcache'),
'enrol' => array('authorize'),
'portfolio' => array('picasa'),
'media' => array('swf'),
'qformat' => array('webct'),
'message' => array('jabber'),
'quizaccess' => array('safebrowser'),
Expand Down Expand Up @@ -1909,7 +1910,7 @@ public static function standard_plugins_list($type) {
),

'media' => array(
'html5audio', 'html5video', 'swf', 'videojs', 'vimeo', 'youtube'
'html5audio', 'html5video', 'videojs', 'vimeo', 'youtube'
),

'message' => array(
Expand Down
2 changes: 1 addition & 1 deletion lib/db/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function xmldb_main_install() {
'filterall' => 0, // setting page, so have to be initialised here.
'texteditors' => 'atto,tinymce,textarea',
'antiviruses' => '',
'media_plugins_sortorder' => 'videojs,youtube,swf',
'media_plugins_sortorder' => 'videojs,youtube',
'upgrade_extracreditweightsstepignored' => 1, // New installs should not run this upgrade step.
'upgrade_calculatedgradeitemsignored' => 1, // New installs should not run this upgrade step.
'upgrade_letterboundarycourses' => 1, // New installs should not run this upgrade step.
Expand Down
9 changes: 9 additions & 0 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2833,5 +2833,14 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2021091700.03);
}

if ($oldversion < 2021091700.04) {
// Remove media_swf (unless it has manually been added back).
if (!file_exists($CFG->dirroot . '/media/player/swf/classes/plugin.php')) {
unset_all_config_for_plugin('media_swf');
}

upgrade_main_savepoint(true, 2021091700.04);
}

return true;
}
23 changes: 6 additions & 17 deletions lib/tests/medialib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ public function test_get_players() {
$manager = core_media_manager::instance();
$this->assertSame('youtube, html5audio', $this->get_players_test($manager));

// Test SWF and HTML5 media order.
\core\plugininfo\media::set_enabled_plugins('html5video,html5audio,swf');
// Test HTML5 media order.
\core\plugininfo\media::set_enabled_plugins('html5video,html5audio');
$manager = core_media_manager::instance();
$this->assertSame('html5video, html5audio, swf', $this->get_players_test($manager));
$this->assertSame('html5video, html5audio', $this->get_players_test($manager));

// Make sure that our test plugin is considered installed.
\core\plugininfo\media::set_enabled_plugins('test,html5video');
Expand Down Expand Up @@ -181,11 +181,6 @@ public function test_can_embed_url() {
\core\plugininfo\media::set_enabled_plugins('html5video');
$manager = core_media_manager::instance();
$this->assertTrue($manager->can_embed_url($url));

// Only SWF.
\core\plugininfo\media::set_enabled_plugins('swf');
$manager = core_media_manager::instance();
$this->assertFalse($manager->can_embed_url($url));
}

/**
Expand All @@ -195,7 +190,6 @@ public function test_can_embed_url() {
public function test_embed_url_fallbacks() {

// Key strings in the embed code that identify with the media formats being tested.
$swf = '</object>';
$html5video = '</video>';
$html5audio = '</audio>';
$link = 'mediafallbacklink';
Expand All @@ -218,7 +212,7 @@ public function test_embed_url_fallbacks() {
$this->assertStringContainsString($link, $t);

// Enable media players that can play the same media formats. (ie. test & html5audio for mp3 files, etc.)
\core\plugininfo\media::set_enabled_plugins('test,html5video,html5audio,swf');
\core\plugininfo\media::set_enabled_plugins('test,html5video,html5audio');
$manager = core_media_manager::instance();

// Test media formats that can be played by 2 or more players.
Expand All @@ -234,27 +228,23 @@ public function test_embed_url_fallbacks() {
$this->assertStringContainsString($test, $textwithlink);
$this->assertStringNotContainsString($html5video, $textwithlink);
$this->assertStringContainsString($html5audio, $textwithlink);
$this->assertStringNotContainsString($swf, $textwithlink);
$this->assertStringContainsString($link, $textwithlink);

$this->assertStringContainsString($test, $textwithoutlink);
$this->assertStringNotContainsString($html5video, $textwithoutlink);
$this->assertStringContainsString($html5audio, $textwithoutlink);
$this->assertStringNotContainsString($swf, $textwithoutlink);
$this->assertStringNotContainsString($link, $textwithoutlink);
break;

case 'mp4':
$this->assertStringContainsString($test, $textwithlink);
$this->assertStringContainsString($html5video, $textwithlink);
$this->assertStringNotContainsString($html5audio, $textwithlink);
$this->assertStringNotContainsString($swf, $textwithlink);
$this->assertStringContainsString($link, $textwithlink);

$this->assertStringContainsString($test, $textwithoutlink);
$this->assertStringContainsString($html5video, $textwithoutlink);
$this->assertStringNotContainsString($html5audio, $textwithoutlink);
$this->assertStringNotContainsString($swf, $textwithoutlink);
$this->assertStringNotContainsString($link, $textwithoutlink);
break;

Expand All @@ -266,10 +256,9 @@ public function test_embed_url_fallbacks() {

/**
* Test for embed_url.
* Check SWF works including the special option required to enable it
* SWF shouldn't be converted to objects because media_swf has been removed.
*/
public function test_embed_url_swf() {
\core\plugininfo\media::set_enabled_plugins('swf');
$manager = core_media_manager::instance();

// Without any options...
Expand All @@ -280,7 +269,7 @@ public function test_embed_url_swf() {
// ...and with the 'no it's safe, I checked it' option.
$url = new moodle_url('http://example.org/test.swf');
$t = $manager->embed_url($url, '', 0, 0, array(core_media_manager::OPTION_TRUSTED => true));
$this->assertStringContainsString('</object>', $t);
$this->assertStringNotContainsString('</object>', $t);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ information provided here is intended especially for developers.
DB call on every request.
* As the message_jabber notification plugin has been moved to the plugins database, the XMPPHP library (aka Jabber) has been
completely removed from Moodle core too.
* The SWF media player has been completely removed (The Flash Player was deprecated in 2017 and officially discontinued
on 31 December 2020).

=== 3.11.2 ===
* For security reasons, filelib has been updated so all requests now use emulated redirects.
Expand Down
3 changes: 2 additions & 1 deletion media/classes/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ final class core_media_manager {
* Option: Enable players which are only suitable for use when we trust the
* user who embedded the content.
*
* At present, this option enables the SWF player.
* In the past, this option enabled the SWF player (which was removed).
* However, this setting will remain because it might be used by third-party plugins.
*
* To enable, set value to true.
*/
Expand Down
Loading

0 comments on commit 0e979b8

Please sign in to comment.