Avoid URL decoding; remove dead code; add encoding to XML Declaration in php_savefile extension

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2663 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Brett Zamir 2014-02-01 16:42:46 +00:00
parent 21c946fd99
commit 0e9a7a7766
2 changed files with 5 additions and 10 deletions

View File

@ -13,7 +13,7 @@ svgEditor.addExtension("php_savefile", {
var save_svg_action = 'extensions/savefile.php';
svgEditor.setCustomHandlers({
save: function(win, data) {
var svg = "<?xml version=\"1.0\"?>\n" + data,
var svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data,
filename = getFileNameFromTitle();
$.post(save_svg_action, {output_svg: svg, filename: filename});
@ -21,7 +21,3 @@ svgEditor.addExtension("php_savefile", {
});
}
});
this.saveHandler = function(svg) {'use strict';
$.post("svg-editor-save.php", {svg_data: svg});
};

View File

@ -8,10 +8,9 @@
exit;
}
$svg = $_POST['output_svg'];
$filename = (isset($_POST['filename']) && !empty($_POST['filename']) ? preg_replace('@[\\\\/:*?"<>|]@', '_', urldecode($_POST['filename'])) : 'saved') . '.svg'; // These characters are indicated as prohibited by Windows
$output_svg = urldecode($svg);
$file = $filename;
$fh = fopen($file, 'w') or die("Can't open file");
fwrite($fh, $output_svg);
$filename = (isset($_POST['filename']) && !empty($_POST['filename']) ? preg_replace('@[\\\\/:*?"<>|]@u', '_', $_POST['filename']) : 'saved') . '.svg'; // These characters are indicated as prohibited by Windows
$fh = fopen($filename, 'w') or die("Can't open file");
fwrite($fh, $svg);
fclose($fh);
?>