From 7d698995a9490d4f5765876c1ca7fa6a09af0677 Mon Sep 17 00:00:00 2001 From: TamaraGunkel <tamara.nrw@web.de> Date: Thu, 15 Feb 2018 12:12:50 +0100 Subject: [PATCH] Fixes #7 replaced hardcoded url in ajax function --- amd/src/form.js | 10 ++++++---- lib.php | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/amd/src/form.js b/amd/src/form.js index adb0e42..2baaa55 100644 --- a/amd/src/form.js +++ b/amd/src/form.js @@ -21,17 +21,19 @@ * @copyright 2018 Tamara Gunkel * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -define(['jquery'], function ($) { +define(['jquery'], function($) { var t = { /* * Submits lti form and updates the source attribute of the video iframes */ - init: function () { - $('#ltiLaunchForm').submit(function (e) { + init: function() { + $('#ltiLaunchForm').submit(function(e) { e.preventDefault(); + var ocurl = decodeURIComponent($(this).attr("action")); + $.ajax({ - url: 'http://localhost:8080/lti', + url: ocurl, crossDomain: true, type: 'post', xhrFields: {withCredentials: true}, diff --git a/lib.php b/lib.php index 2cf9b0b..ce23b44 100644 --- a/lib.php +++ b/lib.php @@ -85,7 +85,7 @@ function filter_opencast_login() { $params['oauth_signature_method'] = 'HMAC-SHA1'; $params['oauth_signature'] = $helper->sign("POST", $endpoint, $params, $consumersecret . '&'); - $content = "<form action=\"" . $endpoint . + $content = "<form action=\"" . urlencode($endpoint) . "\" name=\"ltiLaunchForm\" id=\"ltiLaunchForm\" method=\"post\" encType=\"application/x-www-form-urlencoded\">\n"; // Construct html form for the launch parameters. -- GitLab