From 0957e83d8d5dd864c2d2a8cf246a226a8e7c3b3e Mon Sep 17 00:00:00 2001 From: Daniil Fajnberg Date: Tue, 4 Jan 2022 15:40:01 +0000 Subject: [PATCH] MDL-73498 mod_lti: iframe allowed domain fixed --- mod/lti/view.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mod/lti/view.php b/mod/lti/view.php index adac5fe75f9..7291d028bb5 100644 --- a/mod/lti/view.php +++ b/mod/lti/view.php @@ -72,8 +72,10 @@ if (empty($typeid) && ($tool = lti_get_tool_by_url_match($lti->toolurl))) { } if ($typeid) { $toolconfig = lti_get_type_config($typeid); + $toolurl = $toolconfig['toolurl']; } else { $toolconfig = array(); + $toolurl = $lti->toolurl; } $PAGE->set_cm($cm, $course); // Set's up global $COURSE. @@ -151,11 +153,11 @@ if (($launchcontainer == LTI_LAUNCH_CONTAINER_WINDOW) && $content = lti_initiate_login($cm->course, $id, $lti, $config); } - // Build the allowed URL, since we know what it will be from $lti->toolurl, - // If the specified toolurl is invalid the iframe won't load, but we still want to avoid parse related errors here. - // So we set an empty default allowed url, and only build a real one if the parse is successful. + // Build the allowed URL, since we know what it will be from $toolurl. + // If the specified URL is invalid, the iframe won't load, but we still want to avoid parse related errors here. + // So we set an empty default allowed URL, and only build a real one if the parse is successful. $ltiallow = ''; - $urlparts = parse_url($lti->toolurl); + $urlparts = parse_url($toolurl); if ($urlparts && array_key_exists('scheme', $urlparts) && array_key_exists('host', $urlparts)) { $ltiallow = $urlparts['scheme'] . '://' . $urlparts['host']; // If a port has been specified we append that too.