mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-46269 tool_httpsreplace: Make param search case insensitive
This commit is contained in:
parent
6163651e76
commit
4b86dd7ba6
admin/tool/httpsreplace
@ -153,7 +153,7 @@ class url_finder {
|
||||
|
||||
if (in_array($column->type, $texttypes)) {
|
||||
$columnname = $column->name;
|
||||
$select = "$columnname $regexp ?";
|
||||
$select = "LOWER($columnname) $regexp ?";
|
||||
$rs = $DB->get_recordset_select($table, $select, [$httpurls]);
|
||||
|
||||
$found = array();
|
||||
@ -161,7 +161,7 @@ class url_finder {
|
||||
// Regex to match src=http://etc. and data=http://etc.urls.
|
||||
// Standard warning on expecting regex to perfectly parse HTML
|
||||
// read http://stackoverflow.com/a/1732454 for more info.
|
||||
$regex = '#(src|data)\ *=\ *[\'\"]http://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))[\'\"]#';
|
||||
$regex = '#(src|data)\ *=\ *[\'\"]http://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))[\'\"]#i';
|
||||
preg_match_all($regex, $record->$columnname, $match);
|
||||
foreach ($match[0] as $url) {
|
||||
if (strpos($url, $CFG->wwwroot) !== false) {
|
||||
|
@ -74,6 +74,11 @@ class httpsreplace_test extends \advanced_testcase {
|
||||
"outputregex" => '/^$/',
|
||||
"expectedcontent" => '<img src="https://anothersite.com?param=http://asdf.com">',
|
||||
],
|
||||
"Search for params should be case insensitive" => [
|
||||
"content" => '<object DATA="' . $this->getExternalTestFileUrl('/test.swf', false) . '">',
|
||||
"outputregex" => '/UPDATE/',
|
||||
"expectedcontent" => '<object DATA="' . $this->getExternalTestFileUrl('/test.swf', true) . '">',
|
||||
],
|
||||
"More params should not interfere" => [
|
||||
"content" => '<img alt="A picture" src="' . $this->getExternalTestFileUrl('/test.png', false) . '" width="1”><p style="font-size: \'20px\'"></p>',
|
||||
"outputregex" => '/UPDATE/',
|
||||
|
Loading…
x
Reference in New Issue
Block a user