Skip to content

Commit

Permalink
MDL-59908 backup: Backup rule should use both http and https schemes
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitagarwal committed Aug 24, 2017
1 parent 2387607 commit d477c4e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions backup/moodle2/backup_course_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,25 @@ static public function encode_content_links($content) {
/**
* Helper method, used by encode_content_links.
* @param string $content content in which to encode links.
* @param unknown_type $name the name of this type of encoded link.
* @param unknown_type $path the path that identifies this type of link, up
* @param string $name the name of this type of encoded link.
* @param string $path the path that identifies this type of link, up
* to the ?paramname= bit.
* @return string content with one type of link encoded.
*/
static private function encode_links_helper($content, $name, $path) {
global $CFG;
$base = preg_quote($CFG->wwwroot . $path, '/');
return preg_replace('/(' . $base . ')([0-9]+)/', '$@' . $name . '*$2@$', $content);
// We want to convert both http and https links.
$root = $CFG->wwwroot;
$httpsroot = str_replace('http://', 'https://', $root);
$httproot = str_replace('https://', 'http://', $root);

$httpsbase = preg_quote($httpsroot . $path, '/');
$httpbase = preg_quote($httproot . $path, '/');

$return = preg_replace('/(' . $httpsbase . ')([0-9]+)/', '$@' . $name . '*$2@$', $content);
$return = preg_replace('/(' . $httpbase . ')([0-9]+)/', '$@' . $name . '*$2@$', $return);

return $return;
}

// Protected API starts here
Expand Down

0 comments on commit d477c4e

Please sign in to comment.