Skip to content

Commit 3000bfd

Browse files
committed
accept file:// as safe origin for widgets (required for Cordova)
1 parent 9b3a812 commit 3000bfd

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

www/scripts/sepiaFW.frames.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,10 @@ function sepiaFW_build_frames(){
158158
//get HTML - is there a language dependent version?
159159
var framePage = Frames.getLocalOrDefaultPage(info.pageUrl, SepiaFW.config.appLanguage).trim();
160160
var isValidLocalURL = SepiaFW.tools.isRelativeFileUrl(framePage, "html");
161+
var isAcceptableFileOrigin = (framePage.indexOf("file://") == 0); //any other condition? - This is important for Android (Cordova)
161162
var isTrustedRemoteUrl = SepiaFW.tools.isRemoteFileUrl(framePage, "html")
162163
&& (SepiaFW.tools.isSameOrigin(framePage) || SepiaFW.config.urlIsSepiaFileHost(framePage));
163-
var isTrusted = isValidLocalURL || isTrustedRemoteUrl;
164+
var isTrusted = isValidLocalURL || isAcceptableFileOrigin || isTrustedRemoteUrl;
164165

165166
//$.get(framePage, function(frameHtml){
166167
SepiaFW.files.fetch(framePage, function(frameHtml){

www/scripts/sepiaFW.ui.cards.embed.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,10 @@ function sepiaFW_build_ui_cards_embed(){
213213
widgetUrl = SepiaFW.config.replacePathTagWithActualPath(widgetUrl);
214214
//check URL - NOTE: currently we do not allow unknown URLs
215215
var isValidLocalURL = SepiaFW.tools.isRelativeFileUrl(widgetUrl, "html");
216+
var isAcceptableFileOrigin = (widgetUrl.indexOf("file://") == 0); //any other condition? - This is important for Android (Cordova)
216217
var isTrustedRemoteUrl = SepiaFW.tools.isRemoteFileUrl(widgetUrl, "html")
217218
&& (SepiaFW.tools.isSameOrigin(widgetUrl) || SepiaFW.config.urlIsSepiaFileHost(widgetUrl));
218-
var widgetIsTrusted = isValidLocalURL || isTrustedRemoteUrl;
219+
var widgetIsTrusted = isValidLocalURL || isAcceptableFileOrigin || isTrustedRemoteUrl;
219220
if (!widgetIsTrusted){
220221
SepiaFW.debug.error("WARNING: Embedded MediaPlayer Widget URL has remote location and was BLOCKED due to security restrictions! - URL: " + widgetUrl);
221222
SepiaFW.ui.showSafeWarningPopup("Warning", [
@@ -485,8 +486,9 @@ function sepiaFW_build_ui_cards_embed(){
485486

486487
//Content
487488
thisPlayer.mediaRequest = function(type, request, autoplay, safeRequest, doneCallback, errorCallback){
489+
SepiaFW.debug.info("Embedded MediaPlayer - MediaRequest: " + type + " - autoplay: " + !!(autoplay && widgetIsTrusted));
488490
SepiaFW.audio.broadcastAudioEvent("embedded-media-player", "prepare");
489-
if (autoplay){
491+
if (autoplay && widgetIsTrusted){
490492
//stop all previous audio first
491493
SepiaFW.client.controls.media({
492494
action: "stop",

0 commit comments

Comments
 (0)