From b33e373503c6f64118ec77bb34dc8224d54da4e3 Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Fri, 17 Mar 2023 13:13:13 +0100 Subject: [PATCH] Drag & Drop: set a link as external Summary: Rest assured: external links remain evil, by default. Don't adopt them randomly by induction. Whether you believe it or not, this specific external link merited some deep thoughts on Phorge: - https://we.phorge.it/T15172 So, whenever you use a mouse, a finger, or whenever we have a confirmation dialog or not to prevent onblur disasters, this change is probably consistent with common expectations. Having said, external links remain evil - by default. Closes T15172 Test Plan: - Drag & Drop a File on a Remarkup text - click on the link inside the popup - it opens in a new tab (without risk of form loss) Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: speck, tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T15172 Differential Revision: https://we.phorge.it/D25077 --- webroot/rsrc/js/core/FileUpload.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/webroot/rsrc/js/core/FileUpload.js b/webroot/rsrc/js/core/FileUpload.js index e2c3530cbd..ef5089a56e 100644 --- a/webroot/rsrc/js/core/FileUpload.js +++ b/webroot/rsrc/js/core/FileUpload.js @@ -115,7 +115,19 @@ JX.install('PhabricatorFileUpload', { switch (this.getStatus()) { case 'done': - var link = JX.$N('a', {href: this.getPageURI()}, this.getMonogram()); + + // In this case the File upload was successful + + var linkAttr = {}; + linkAttr.href = this.getPageURI(); + + // External links are evil as default. + // Believe it or not, but some Phorge users brainstormed + // for one hour for this specific target="_blank". + // https://we.phorge.it/T15172 + linkAttr.target = '_blank'; + + var link = JX.$N('a', linkAttr, this.getMonogram()); content = [ JX.$N('strong', {}, ['Upload Complete (', link, ')']),