Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'MDL-36204_22' of git://github.com/pauln/moodle into MOO…

…DLE_22_STABLE
  • Loading branch information...
commit 521225275bb92f7b6e8913a90be005d8aa40f016 2 parents 80b7e5d + 2b046f8
@danpoltawski danpoltawski authored
View
3  backup/converter/moodle1/lib.php
@@ -640,7 +640,8 @@ public static function find_referenced_files($text) {
return $files;
}
foreach ($matches[2] as $match) {
- $files[] = str_replace(array('$@FILEPHP@$', '$@SLASH@$', '$@FORCEDOWNLOAD@$'), array('', '/', ''), $match);
+ $file = str_replace(array('$@FILEPHP@$', '$@SLASH@$', '$@FORCEDOWNLOAD@$'), array('', '/', ''), $match);
+ $files[] = urldecode($file);
}
return array_unique($files);
View
13 backup/converter/moodle1/simpletest/testlib.php
@@ -435,6 +435,19 @@ public function test_referenced_course_files() {
<br /><a href=\'$@FILEPHP@$$@SLASH@$MANUAL.DOC$@FORCEDOWNLOAD@$\'>download manual</a><br />');
}
+ public function test_referenced_files_urlencoded() {
+ // This test covers MDL-36204
+ $text = 'This is a text containing links to file.php
+as it is parsed from the backup file. <br /><br /><img border="0" width="110" vspace="0" hspace="0" height="92" title="News" alt="News" src="$@FILEPHP@$$@SLASH@$pics$@SLASH@$news.gif" /><a href="$@FILEPHP@$$@SLASH@$pics$@SLASH@$news.gif$@FORCEDOWNLOAD@$">no space</a><br />
+ <br /><a href=\'$@FILEPHP@$$@SLASH@$pics$@SLASH@$news%20with%20spaces.gif$@FORCEDOWNLOAD@$\'>with urlencoded spaces</a><br />';
+
+ $files = moodle1_converter::find_referenced_files($text);
+ $this->assertIsA($files, 'array');
+ $this->assertEqual(2, count($files));
+ $this->assertTrue(in_array('/pics/news.gif', $files));
+ $this->assertTrue(in_array('/pics/news with spaces.gif', $files));
+ }
+
public function test_question_bank_conversion() {
global $CFG;
Please sign in to comment.
Something went wrong with that request. Please try again.