MDL-72988 mod_lti: improved handling of missing tool endpoint.

This commit is contained in:
Paul Holden 2021-11-18 22:45:06 +00:00
parent eab63d2cfe
commit 9a56e2ba1f
2 changed files with 13 additions and 7 deletions

View File

@ -445,10 +445,15 @@ class OAuthRequest {
}
/**
* parses the url and rebuilds it to be
* scheme://host/path
* Parses {@see http_url} and returns normalized scheme://host/path if non-empty, otherwise return empty string
*
* @return string
*/
public function get_normalized_http_url() {
if ($this->http_url === '') {
return '';
}
$parts = parse_url($this->http_url);
$port = @$parts['port'];

View File

@ -593,11 +593,11 @@ function lti_get_launch_data($instance, $nonce = '') {
$endpoint = trim($instance->securetoolurl);
}
$endpoint = lti_ensure_url_is_https($endpoint);
} else {
if (!strstr($endpoint, '://')) {
$endpoint = 'http://' . $endpoint;
if ($endpoint !== '') {
$endpoint = lti_ensure_url_is_https($endpoint);
}
} else if ($endpoint !== '' && !strstr($endpoint, '://')) {
$endpoint = 'http://' . $endpoint;
}
$orgid = lti_get_organizationid($typeconfig);
@ -3455,7 +3455,8 @@ function lti_post_launch_html($newparms, $endpoint, $debug=false) {
}
$r .= "</form>\n";
if ( ! $debug ) {
// Auto-submit the form if endpoint is set.
if ($endpoint !== '' && !$debug) {
$r .= " <script type=\"text/javascript\"> \n" .
" //<![CDATA[ \n" .
" document.ltiLaunchForm.submit(); \n" .