From c2d545e3cd4ec2f2abd3f94c9bdbaac61fab4ac7 Mon Sep 17 00:00:00 2001
From: Andreas Fernandez <a.fernandez@scripting-base.de>
Date: Sat, 15 Feb 2020 12:27:30 +0100
Subject: [PATCH] [BUGFIX] Use correct target to trigger file deletion

Use the correct target (clicked button) to be able to access the button name.

Resolves: #90036
Releases: master
Change-Id: I3a2face0c10aa41dea13bc49d3f8f3e9f47b3fcc
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63251
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Tested-by: TYPO3com <noreply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
---
 .../filelist/Resources/Public/TypeScript/ContextMenuActions.ts  | 2 +-
 .../filelist/Resources/Public/JavaScript/ContextMenuActions.js  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Build/Sources/TypeScript/filelist/Resources/Public/TypeScript/ContextMenuActions.ts b/Build/Sources/TypeScript/filelist/Resources/Public/TypeScript/ContextMenuActions.ts
index b048b0d4d67c..14e109bbff0f 100644
--- a/Build/Sources/TypeScript/filelist/Resources/Public/TypeScript/ContextMenuActions.ts
+++ b/Build/Sources/TypeScript/filelist/Resources/Public/TypeScript/ContextMenuActions.ts
@@ -101,7 +101,7 @@ class ContextMenuActions {
       ]);
 
     $modal.on('button.clicked', (e: JQueryEventObject): void => {
-      const $element: HTMLInputElement = <HTMLInputElement>e.currentTarget;
+      const $element: HTMLInputElement = <HTMLInputElement>e.target;
       if ($element.name === 'delete') {
         performDelete();
       }
diff --git a/typo3/sysext/filelist/Resources/Public/JavaScript/ContextMenuActions.js b/typo3/sysext/filelist/Resources/Public/JavaScript/ContextMenuActions.js
index b7349acfb328..6df8df781b87 100644
--- a/typo3/sysext/filelist/Resources/Public/JavaScript/ContextMenuActions.js
+++ b/typo3/sysext/filelist/Resources/Public/JavaScript/ContextMenuActions.js
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","TYPO3/CMS/Backend/Enum/Severity","jquery","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Hashing/Md5"],(function(t,e,n,o,a,r,s){"use strict";class i{static getReturnUrl(){return encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search)}static renameFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileRename.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static editFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileEdit.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static editFileStorage(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit[sys_file_storage]["+parseInt(e,10)+"]=edit&returnUrl="+i.getReturnUrl())}static openInfoPopUp(t,e){"sys_file_storage"===t?top.TYPO3.InfoWindow.showItem(t,e):top.TYPO3.InfoWindow.showItem("_FILE",e)}static uploadFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileUpload.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static createFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCreate.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static deleteFile(t,e){const a=o(this),s=()=>{top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&data[delete][0][data]="+encodeURIComponent(e)+"&data[delete][0][redirect]="+i.getReturnUrl())};a.data("title")?r.confirm(a.data("title"),a.data("message"),n.SeverityEnum.warning,[{text:o(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:o(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",t=>{"delete"===t.currentTarget.name&&s(),r.dismiss()}):s()}static copyFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:e},setCopyMode:"1"}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static copyReleaseFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:"0"},setCopyMode:"1"}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static cutFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:e}}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static cutReleaseFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:"0"}}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static pasteFileInto(t,e){const a=o(this),s=a.data("title"),l=()=>{top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&CB[paste]=FILE|"+encodeURIComponent(e)+"&CB[pad]=normal&redirect="+i.getReturnUrl())};s?r.confirm(s,a.data("message"),n.SeverityEnum.warning,[{text:o(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:o(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",t=>{"ok"===t.target.name&&l(),r.dismiss()}):l()}static dropInto(t,e,n){const a=o(this).data("drop-target");top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&file["+n+"][0][data]="+encodeURIComponent(e)+"&file["+n+"][0][target]="+encodeURIComponent(a)+"&redirect="+i.getReturnUrl())}static dropMoveInto(t,e){i.dropInto.bind(o(this))(t,e,"move")}static dropCopyInto(t,e){i.dropInto.bind(o(this))(t,e,"copy")}}return i}));
\ No newline at end of file
+define(["require","exports","TYPO3/CMS/Backend/Enum/Severity","jquery","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Hashing/Md5"],(function(t,e,n,o,a,r,s){"use strict";class i{static getReturnUrl(){return encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search)}static renameFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileRename.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static editFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileEdit.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static editFileStorage(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit[sys_file_storage]["+parseInt(e,10)+"]=edit&returnUrl="+i.getReturnUrl())}static openInfoPopUp(t,e){"sys_file_storage"===t?top.TYPO3.InfoWindow.showItem(t,e):top.TYPO3.InfoWindow.showItem("_FILE",e)}static uploadFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileUpload.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static createFile(t,e){top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCreate.moduleUrl+"&target="+encodeURIComponent(e)+"&returnUrl="+i.getReturnUrl())}static deleteFile(t,e){const a=o(this),s=()=>{top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&data[delete][0][data]="+encodeURIComponent(e)+"&data[delete][0][redirect]="+i.getReturnUrl())};a.data("title")?r.confirm(a.data("title"),a.data("message"),n.SeverityEnum.warning,[{text:o(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:o(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",t=>{"delete"===t.target.name&&s(),r.dismiss()}):s()}static copyFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:e},setCopyMode:"1"}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static copyReleaseFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:"0"},setCopyMode:"1"}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static cutFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:e}}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static cutReleaseFile(t,e){const n=s.hash(e).substring(0,10),o=TYPO3.settings.ajaxUrls.contextmenu_clipboard,r={CB:{el:{["_FILE%7C"+n]:"0"}}};new a(o).withQueryArguments(r).get().finally(()=>{top.TYPO3.Backend.ContentContainer.refresh(!0)})}static pasteFileInto(t,e){const a=o(this),s=a.data("title"),l=()=>{top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&CB[paste]=FILE|"+encodeURIComponent(e)+"&CB[pad]=normal&redirect="+i.getReturnUrl())};s?r.confirm(s,a.data("message"),n.SeverityEnum.warning,[{text:o(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:o(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",t=>{"ok"===t.target.name&&l(),r.dismiss()}):l()}static dropInto(t,e,n){const a=o(this).data("drop-target");top.TYPO3.Backend.ContentContainer.setUrl(top.TYPO3.settings.FileCommit.moduleUrl+"&file["+n+"][0][data]="+encodeURIComponent(e)+"&file["+n+"][0][target]="+encodeURIComponent(a)+"&redirect="+i.getReturnUrl())}static dropMoveInto(t,e){i.dropInto.bind(o(this))(t,e,"move")}static dropCopyInto(t,e){i.dropInto.bind(o(this))(t,e,"copy")}}return i}));
\ No newline at end of file
-- 
GitLab