From c379d59daa4b1bfe2c09afa1f22ca010a7668c23 Mon Sep 17 00:00:00 2001 From: Pablo Ogando Ferreira Date: Thu, 14 Nov 2024 11:31:26 +0100 Subject: [PATCH] Use URL instead of iframe to remove blocks from Moodle security. Filter will convert URLs on iframes (#10) --- version.php | 4 ++-- .../moodle-atto_pumukitmedia-button-debug.js | 7 +------ .../moodle-atto_pumukitmedia-button-min.js | 2 +- .../moodle-atto_pumukitmedia-button.js | 7 +------ yui/src/button/js/button.js | 13 +++++++------ 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/version.php b/version.php index 3e0de33..de18553 100644 --- a/version.php +++ b/version.php @@ -25,11 +25,11 @@ defined('MOODLE_INTERNAL') || exit(); -$plugin->version = 2023024601; +$plugin->version = 2024070302; $plugin->requires = 2016112900; $plugin->maturity = MATURITY_STABLE; $plugin->component = 'atto_pumukitmedia'; $plugin->dependencies = [ 'filter_pumukitmedia' => 2022021801 ]; -$plugin->release = '1'; +$plugin->release = '1.1.0'; diff --git a/yui/build/moodle-atto_pumukitmedia-button/moodle-atto_pumukitmedia-button-debug.js b/yui/build/moodle-atto_pumukitmedia-button/moodle-atto_pumukitmedia-button-debug.js index cf3ce1c..3c0e06b 100644 --- a/yui/build/moodle-atto_pumukitmedia-button/moodle-atto_pumukitmedia-button-debug.js +++ b/yui/build/moodle-atto_pumukitmedia-button/moodle-atto_pumukitmedia-button-debug.js @@ -341,12 +341,7 @@ Y.namespace('M.atto_pumukitmedia').Button = Y.Base.create('button', Y.M.editor_a url = e.data.url; } - var iframe = - '
' + - '' + - 'Video' + - '
'; + var iframe = '' + url + ''; this.get('host').insertContentAtFocusPoint(iframe); this.markUpdated(); }, diff --git a/yui/build/moodle-atto_pumukitmedia-button/moodle-atto_pumukitmedia-button-min.js b/yui/build/moodle-atto_pumukitmedia-button/moodle-atto_pumukitmedia-button-min.js index 494ed2f..1e14dbd 100644 --- a/yui/build/moodle-atto_pumukitmedia-button/moodle-atto_pumukitmedia-button-min.js +++ b/yui/build/moodle-atto_pumukitmedia-button/moodle-atto_pumukitmedia-button-min.js @@ -1,2 +1,2 @@ YUI.add("moodle-atto_pumukitmedia-button",function(e,t){var n="atto_pumukitmedia",r="pumukitmedia_flavor",i="atto_pumukitmedia",s={INPUTSUBMIT:"atto_media_urlentrysubmit",INPUTCANCEL:"atto_media_urlentrycancel",FLAVORCONTROL:"flavorcontrol"},o={FLAVORCONTROL:".flavorcontrol"},u='",o=o+""+'
'+''+"
",i+=o;var f=e.Handlebars.compile(i),l=e.Node.create(f({elementid:this.get("host").get("elementid"),CSS:s,FLAVORCONTROL:r,PUMUKITURL:this.get("pumukitmediaurl"),HASH:this.get("hash"),USERNAME:this.get("username"),EMAIL:this.get("email"),CAPABILITY:this.get("capability"),PASSWORD:this.get("password"),DATE:this.get("date"),DEBUG:this.get("enabledebugmode"),component:n,defaultflavor:this.get("defaultflavor"),clickedicon:t,button_upload:M.util.get_string("button_upload",n),button_pr:M.util.get_string("button_pr",n),button_myvideos:M.util.get_string("button_myvideos",n),button_playlists:M.util.get_string("button_playlists",n),button_sharevideos:M.util.get_string("button_sharevideos",n)}));return this.get("enabledebugmode")==1&&(console.log("URL: "+this.get("pumukitmediaurl")),console.log("Date: "+this.get("date")),console.log("Hash: "+this.get("hash")),console.log("User: "+this.get("username")),console.log("Email: "+this.get("email")),console.log("Pwd: "+this.get("password"))),this._form=l,l},_doInsert:function(e){e.preventDefault(),this.getDialogue({focusAfterHide:null}).hide();var t=this._form.one(o.FLAVORCONTROL);if(!t.get("value"))return;this.editor.focus(),this.get("host").insertContentAtFocusPoint(t.get("value")),this.markUpdated()},_receiveMessage:function(e){e.data==="enableMoodlePRAdd?"&&e.source.postMessage({moodlepradd:"OK"},"*");if(!e.data.mmId&&!e.data.playlist&&!e.data.url)return;e.preventDefault(),this.getDialogue({focusAfterHide:null}).hide(),this._closeSharedWindow(e);if(!e.data.mmId&&!e.data.playlist&&!e.data.url)return;window.removeEventListener("message",this._receiveMessageBind),this.editor.focus();var t=this.get("pumukitmediaurl")+"/openedx/openedx/embed/"+e.data.mmId;e.data.playlist?t=this.get("pumukitmediaurl")+"/openedx/openedx/playlist/embed/"+ -e.data.playlist:e.data.url&&(t=e.data.url);var n='
'+'Video'+"
";this.get("host").insertContentAtFocusPoint(n),this.markUpdated()},_closeSharedWindow:function(){var e=document.getElementById("pumukitmedia_iframe_recorder");e.parentNode.removeChild(e)}},{ATTRS:{pumukitmediaurl:{value:""},hash:{value:""},username:{value:""},email:{value:""},dialogtitle:{value:""},showpr:{value:""},showplaylist:{value:""},showsharedvideos:{value:""},capability:{value:""},password:{value:""},date:{value:""},enabledebugmode:{value:""}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); +e.data.playlist:e.data.url&&(t=e.data.url);var n=''+t+'';this.get("host").insertContentAtFocusPoint(n),this.markUpdated()},_closeSharedWindow:function(){var e=document.getElementById("pumukitmedia_iframe_recorder");e.parentNode.removeChild(e)}},{ATTRS:{pumukitmediaurl:{value:""},hash:{value:""},username:{value:""},email:{value:""},dialogtitle:{value:""},showpr:{value:""},showplaylist:{value:""},showsharedvideos:{value:""},capability:{value:""},password:{value:""},date:{value:""},enabledebugmode:{value:""}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); diff --git a/yui/build/moodle-atto_pumukitmedia-button/moodle-atto_pumukitmedia-button.js b/yui/build/moodle-atto_pumukitmedia-button/moodle-atto_pumukitmedia-button.js index 09b2676..23d9482 100644 --- a/yui/build/moodle-atto_pumukitmedia-button/moodle-atto_pumukitmedia-button.js +++ b/yui/build/moodle-atto_pumukitmedia-button/moodle-atto_pumukitmedia-button.js @@ -339,12 +339,7 @@ Y.namespace('M.atto_pumukitmedia').Button = Y.Base.create('button', Y.M.editor_a url = e.data.url; } - var iframe = - '
' + - '' + - 'Video' + - '
'; + var iframe = '' + url + ''; this.get('host').insertContentAtFocusPoint(iframe); this.markUpdated(); }, diff --git a/yui/src/button/js/button.js b/yui/src/button/js/button.js index ea9adcc..f13a141 100644 --- a/yui/src/button/js/button.js +++ b/yui/src/button/js/button.js @@ -339,12 +339,13 @@ Y.namespace('M.atto_pumukitmedia').Button = Y.Base.create('button', Y.M.editor_a url = e.data.url; } - var iframe = - '
' + - '' + - 'Video' + - '
'; + // var iframe = + // '
' + + // '' + + // 'Video' + + // '
'; + var iframe = '' + url + ''; this.get('host').insertContentAtFocusPoint(iframe); this.markUpdated(); },