Skip to content

Commit

Permalink
Fixes problem with drag and drop in Safari
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Jermolene committed Feb 11, 2015
1 parent 1534fed commit c9ab873
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/modules/widgets/dropzone.js
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions core/modules/widgets/link.js
Expand Up @@ -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 {
Expand Down

0 comments on commit c9ab873

Please sign in to comment.