diff --git a/tiddlyfox/extension/content/inject.js b/tiddlyfox/extension/content/inject.js index caa732290..99673c4d1 100644 --- a/tiddlyfox/extension/content/inject.js +++ b/tiddlyfox/extension/content/inject.js @@ -13,8 +13,8 @@ The JavaScript in this file is injected into each TiddlyWiki page that loads if(messageBox) { // Create the message element and put it in the message box var message = document.createElement("div"); - message.setAttribute("tiddlyfox-path",path); - message.setAttribute("tiddlyfox-content",content); + message.setAttribute("data-tiddlyfox-path",path); + message.setAttribute("data-tiddlyfox-content",content); messageBox.appendChild(message); // Create and dispatch the custom event to the extension var event = document.createEvent("Events"); @@ -31,7 +31,7 @@ The JavaScript in this file is injected into each TiddlyWiki page that loads try { // Just the read the file synchronously var xhReq = new XMLHttpRequest(); - xhReq.open("GET", "file://" + path, false); + xhReq.open("GET", "file://" + escape(path), false); xhReq.send(null); return xhReq.responseText; } catch(ex) { @@ -39,7 +39,12 @@ The JavaScript in this file is injected into each TiddlyWiki page that loads } }; + var injectedConvertUriToUTF8 = function(path) { + return path; + } + window.mozillaSaveFile = injectedSaveFile; window.mozillaLoadFile = injectedLoadFile; + window.convertUriToUTF8 = injectedConvertUriToUTF8; })(); \ No newline at end of file diff --git a/tiddlyfox/extension/content/overlay.js b/tiddlyfox/extension/content/overlay.js index 7a6ec8caa..e177ba48f 100644 --- a/tiddlyfox/extension/content/overlay.js +++ b/tiddlyfox/extension/content/overlay.js @@ -62,6 +62,14 @@ var TiddlyFox = { }, saveFile: function(filePath,content) { + // Attempt to convert the filepath to a proper UTF-8 string + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var converter = Components.classes["@mozilla.org/intl/utf8converterservice;1"].getService(Components.interfaces.nsIUTF8ConverterService); + filePath = converter.convertURISpecToUTF8(filePath,"UTF-8"); + } catch(ex) { + } + // Save the file try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); @@ -82,8 +90,8 @@ var TiddlyFox = { onSaveFile: function(event) { // Get the details from the message var message = event.target, - path = message.getAttribute("tiddlyfox-path"), - content = message.getAttribute("tiddlyfox-content"); + path = message.getAttribute("data-tiddlyfox-path"), + content = message.getAttribute("data-tiddlyfox-content"); // Save the file TiddlyFox.saveFile(path,content); // Remove the message element from the message box diff --git a/tiddlyfox/extension/tiddlyfox.xpi b/tiddlyfox/extension/tiddlyfox.xpi index 031936319..f57670018 100644 Binary files a/tiddlyfox/extension/tiddlyfox.xpi and b/tiddlyfox/extension/tiddlyfox.xpi differ