From c9ab873ba393753647f2b0b3b3aa1a8bcf6b1c28 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 11 Feb 2015 10:07:10 +0000 Subject: [PATCH] Fixes problem with drag and drop in Safari MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1415 The problem was that encodeURI() doesn’t encode slashes, which are not legal in a data URI, although only Safari was failing. We switch to encodeURIComponent(), which does encode slashes --- core/modules/widgets/dropzone.js | 4 ++-- core/modules/widgets/link.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/modules/widgets/dropzone.js b/core/modules/widgets/dropzone.js index 744e3040c..4ac8e78f4 100644 --- a/core/modules/widgets/dropzone.js +++ b/core/modules/widgets/dropzone.js @@ -159,7 +159,7 @@ DropZoneWidget.prototype.importDataTypes = [ }}, {type: "URL", IECompatible: true, convertToFields: function(data) { // Check for tiddler data URI - var match = decodeURI(data).match(/^data\:text\/vnd\.tiddler,(.*)/i); + var match = decodeURIComponent(data).match(/^data\:text\/vnd\.tiddler,(.*)/i); if(match) { return JSON.parse(match[1]); } else { @@ -170,7 +170,7 @@ DropZoneWidget.prototype.importDataTypes = [ }}, {type: "text/x-moz-url", IECompatible: false, convertToFields: function(data) { // Check for tiddler data URI - var match = decodeURI(data).match(/^data\:text\/vnd\.tiddler,(.*)/i); + var match = decodeURIComponent(data).match(/^data\:text\/vnd\.tiddler,(.*)/i); if(match) { return JSON.parse(match[1]); } else { diff --git a/core/modules/widgets/link.js b/core/modules/widgets/link.js index 6d0d94610..ff7209ec4 100755 --- a/core/modules/widgets/link.js +++ b/core/modules/widgets/link.js @@ -161,9 +161,9 @@ LinkWidget.prototype.handleDragStartEvent = function(event) { if(!$tw.browser.isIE) { dataTransfer.setData("text/vnd.tiddler",jsonData); dataTransfer.setData("text/plain",title); - dataTransfer.setData("text/x-moz-url","data:text/vnd.tiddler," + encodeURI(jsonData)); + dataTransfer.setData("text/x-moz-url","data:text/vnd.tiddler," + encodeURIComponent(jsonData)); } - dataTransfer.setData("URL","data:text/vnd.tiddler," + encodeURI(jsonData)); + dataTransfer.setData("URL","data:text/vnd.tiddler," + encodeURIComponent(jsonData)); dataTransfer.setData("Text",title); event.stopPropagation(); } else {