1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

Fixes problem with drag and drop in Safari

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
This commit is contained in:
Jermolene 2015-02-11 10:07:10 +00:00
parent 1534fed4f7
commit c9ab873ba3
2 changed files with 4 additions and 4 deletions

View File

@ -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 {

View File

@ -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 {