Skip to content

Commit

Permalink
Merge branch 'MDL-73195-311' of https://github.com/lameze/moodle into…
Browse files Browse the repository at this point in the history
… MOODLE_311_STABLE
  • Loading branch information
andrewnicols committed Dec 3, 2021
2 parents df0d1ea + fda79a2 commit 24ffb2c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions mod/url/locallib.php
Expand Up @@ -571,8 +571,16 @@ function url_guess_icon($fullurl, $size = null) {
return null;
}

$moodleurl = new moodle_url($fullurl);
$fullurl = $moodleurl->out_omit_querystring();
try {
// There can be some cases where the url is invalid making parse_url() to return false.
// That will make moodle_url class to throw an exception, so we need to catch the exception to prevent errors.
$moodleurl = new moodle_url($fullurl);
$fullurl = $moodleurl->out_omit_querystring();
} catch (\moodle_exception $e) {
// If an exception is thrown, means the url is invalid. No need to log exception.
return null;
}

$icon = file_extension_icon($fullurl, $size);
$htmlicon = file_extension_icon('.htm', $size);
$unknownicon = file_extension_icon('', $size);
Expand Down

0 comments on commit 24ffb2c

Please sign in to comment.