MDL-59255 media: support rtmp:// in URLs

This commit is contained in:
Marina Glancy
2017-07-18 10:27:11 +01:00
committed by Ruslan Kabalin
parent 4b4243113f
commit 596a156134
2 changed files with 17 additions and 1 deletions
+10
View File
@@ -413,6 +413,16 @@ class core_medialib_testcase extends advanced_testcase {
$this->assertEquals($webm, $result[1]->out(false));
$this->assertEquals(400, $w);
$this->assertEquals(280, $h);
// Support for rtmp.
$rtmp = 'rtmp://rtmpsite.net/somestream';
$result = $mediamanager->split_alternatives($rtmp, $w, $h);
$this->assertEquals($rtmp, $result[0]->out(false));
// Invalid URL is not supported.
$invalid = 'mailto:[email protected]';
$result = $mediamanager->split_alternatives($invalid, $w, $h);
$this->assertEmpty($result);
}
/**
+7 -1
View File
@@ -425,11 +425,17 @@ final class core_media_manager {
$url = str_replace($matches[0], '', $url);
}
// Clean up url.
// Clean up url. Allow rtmp:// protocol even though it's not allowed by clean_param(..., PARAM_URL).
if ($isrtmp = preg_match('|^(rtmp://)(.*)$|i', trim($url), $matches)) {
$url = "http://" . $matches[2];
}
$url = clean_param($url, PARAM_URL);
if (empty($url)) {
continue;
}
if ($isrtmp) {
$url = preg_replace('|^http://|', $matches[1], $url);
}
// Turn it into moodle_url object.
$returnurls[] = new moodle_url($url);