Minor clean-up; UTF-8 for SVG

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2667 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Brett Zamir 2014-02-02 01:06:25 +00:00
parent a5083f0394
commit 1181de6847
4 changed files with 10 additions and 10 deletions

View File

@ -1,7 +1,7 @@
<?php
$allowedMimeTypesBySuffix = array(
'svg' => 'image/svg+xml',
'svg' => 'image/svg+xml;charset=utf-8',
'png' => 'image/png',
'jpeg' => 'image/jpeg',
'bmp' => 'image/bmp',

View File

@ -38,11 +38,10 @@ svgEditor.addExtension("server_opensave", {
$('<iframe name="output_frame" src="#"/>').hide().appendTo('body');
svgEditor.setCustomHandlers({
save: function(win, data) {
var svg = '<?xml version="1.0" encoding="UTF-8"?>\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
var svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data, // Firefox doesn't seem to know it is UTF-8 (no matter whether we use or 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(svg))) {
if (clientDownloadSupport(filename, '.svg', 'data:image/svg+xml;charset=UTF-8;base64,' + svgedit.utilities.encode64(svg))) {
return;
}
@ -105,7 +104,7 @@ svgEditor.addExtension("server_opensave", {
}
});
// Do nothing if client support is found
if (window.FileReader) {return;}
@ -159,7 +158,7 @@ svgEditor.addExtension("server_opensave", {
// Create image form
import_img_form = open_svg_form.clone().attr('action', import_img_action);
// It appears necessory to rebuild this input every time a file is
// It appears necessary to rebuild this input every time a file is
// selected so the same file can be picked and the change event can fire.
function rebuildInput(form) {
form.empty();

View File

@ -25,7 +25,7 @@
$prefix = '';
// Make Data URL prefix for import image
if($type == 'import_img') {
if ($type == 'import_img') {
$info = getimagesize($file);
if (!in_array($info['mime'], $allowedMimeTypesBySuffix)) {
exit;
@ -37,7 +37,8 @@
<head>
<meta charset="utf-8" />
<script>
window.top.window.svgEditor.processFile("<?php
top.svgEditor.processFile("<?php
// This should be safe since SVG edit does its own filtering (e.g., if an SVG file contains scripts)
echo $prefix . base64_encode($output);

View File

@ -20,7 +20,7 @@ function encodeRFC5987ValueChars ($str) {
require('allowedMimeTypes.php');
$mime = !isset($_POST['mime']) || !in_array($_POST['mime'], $allowedMimeTypesBySuffix) ? 'image/svg+xml' : $_POST['mime'];
$mime = !isset($_POST['mime']) || !in_array($_POST['mime'], $allowedMimeTypesBySuffix) ? 'image/svg+xml;charset=UTF-8' : $_POST['mime'];
if (!isset($_POST['output_svg']) && !isset($_POST['output_img'])) {
die('post fail');
@ -52,7 +52,7 @@ header("Content-Disposition: attachment; filename*=UTF-8''" . encodeRFC5987Value
// preg_replace('@[\\\\/:*?"<>|]@', '', $file) // If we wanted to strip Windows-disallowed characters server-side (but not a security issue, so we can strip client-side instead)
$file
));
header("Content-Type: " . $mime . ';charset=utf-8');
header("Content-Type: " . $mime);
header("Content-Transfer-Encoding: binary");
echo $contents;