diff --git a/mod/lti/OAuth.php b/mod/lti/OAuth.php index 6dd60f0bec0..0790c4c5dca 100644 --- a/mod/lti/OAuth.php +++ b/mod/lti/OAuth.php @@ -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']; diff --git a/mod/lti/locallib.php b/mod/lti/locallib.php index 36c61262e09..7668e676631 100644 --- a/mod/lti/locallib.php +++ b/mod/lti/locallib.php @@ -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 .= "\n"; - if ( ! $debug ) { + // Auto-submit the form if endpoint is set. + if ($endpoint !== '' && !$debug) { $r .= "