From d3e417a98488239367f383f44b26394e0ddf35e1 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 9 Jun 2020 16:10:20 -0400 Subject: [PATCH] guard against a type error when downloading the content of a media-tag --- www/common/inner/common-mediatag.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/www/common/inner/common-mediatag.js b/www/common/inner/common-mediatag.js index 3c1f340af..9009d2557 100644 --- a/www/common/inner/common-mediatag.js +++ b/www/common/inner/common-mediatag.js @@ -399,14 +399,16 @@ define([ e.stopPropagation(); m.hide(); var $mt = $menu.data('mediatag'); - if ($(this).hasClass("cp-app-code-context-saveindrive")) { + var $this = $(this); + if ($this.hasClass("cp-app-code-context-saveindrive")) { common.importMediaTag($mt); } - else if ($(this).hasClass("cp-app-code-context-download")) { - var media = $mt[0]._mediaObject; + else if ($this.hasClass("cp-app-code-context-download")) { + var media = Util.find($mt, [0, '_mediaObject']); + if (!(media && media._blob)) { return void console.error($mt); } window.saveAs(media._blob.content, media.name); } - else if ($(this).hasClass("cp-app-code-context-open")) { + else if ($this.hasClass("cp-app-code-context-open")) { $mt.trigger('preview'); } });