diff --git a/editor/extensions/ext-php_savefile.js b/editor/extensions/ext-php_savefile.js index 191ba0cb..e26d07aa 100644 --- a/editor/extensions/ext-php_savefile.js +++ b/editor/extensions/ext-php_savefile.js @@ -8,7 +8,7 @@ svgEditor.addExtension("php_savefile", { 'use strict'; function getFileNameFromTitle () { var title = svgCanvas.getDocumentTitle(); - return $.trim(title); // .replace(/[^a-z0-9\.\_\-]+/gi, '_'); // We could do this more stringent client-side filtering, but we need to do on the server anyways + return $.trim(title); } var save_svg_action = 'extensions/savefile.php'; svgEditor.setCustomHandlers({ diff --git a/editor/extensions/ext-server_opensave.js b/editor/extensions/ext-server_opensave.js index ac7b351b..371c4a33 100644 --- a/editor/extensions/ext-server_opensave.js +++ b/editor/extensions/ext-server_opensave.js @@ -13,7 +13,11 @@ svgEditor.addExtension("server_opensave", { 'use strict'; function getFileNameFromTitle () { var title = svgCanvas.getDocumentTitle(); - return $.trim(title).replace(/[^a-z0-9\.\_\-]+/gi, '_'); + // We convert (to underscore) only those disallowed Win7 file name characters + return $.trim(title).replace(/[\/\\:*?"<>|]/g, '_'); + } + function xhtmlEscape(str) { + return str.replace(/&/g, '&').replace(/"/g, '"').replace(/').hide().appendTo('body'); svgEditor.setCustomHandlers({ save: function(win, data) { - var svg = "\n" + data, + var svg = '\n' + data, // Firefox doesn't seem to know it is UTF-8 (if we skip the clientDownload code) despite the Content-Disposition header containing UTF-8, but adding the encoding works filename = getFileNameFromTitle(); - //if (clientDownloadSupport(filename, '.svg', 'data:image/svg+xml,' + encodeURI(data))) { // Firefox limits size of file - if (clientDownloadSupport(filename, '.svg', 'data:image/svg+xml;base64,' + svgedit.utilities.encode64(data))) { + // if (clientDownloadSupport(filename, '.svg', 'data:image/svg+xml,' + encodeURI(data))) { // Firefox limits size of file + if (clientDownloadSupport(filename, '.svg', 'data:image/svg+xml;base64,' + svgedit.utilities.encode64(svg))) { return; } - + $('