瀏覽代碼

Feature #2044 fix a problem of svg-edit with accents and mimetypes

Juan Carlos Raña 14 年之前
父節點
當前提交
ba7cc920ea

+ 3 - 4
main/inc/lib/svg-edit/extensions/ext-server_opensave.js

@@ -18,11 +18,11 @@ svgEditor.addExtension("server_opensave", {
 	
 		svgEditor.setCustomHandlers({
 			save: function(win, data) {
-				var svg = '<?xml version="1.0"?>' + data;
+				var svg = '<?xml version="1.0" encoding="UTF-8" ?>' + data;// Chamilo add encoding="UTF-8"
 				
 				var title = svgCanvas.getDocumentTitle();
-				var filename = title.replace(/[^a-z0-9\.\_\-]+/gi, '_');
-				
+				//var filename = title.replace(/[^a-z0-9\.\_\-]+/gi, '_');//Chamilo replace by below  
+				var filename =title;//TODO:check if the filter through filesave.php is enough
 				var form = $('<form>').attr({
 					method: 'post',
 					action: save_svg_action,
@@ -176,4 +176,3 @@ svgEditor.addExtension("server_opensave", {
 		$("#tool_image").prepend(import_img_form);
 	}
 });
-

+ 4 - 3
main/inc/lib/svg-edit/extensions/filesave.php

@@ -103,16 +103,17 @@ $filename = disable_dangerous_file($filename);
 $finfo = new finfo(FILEINFO_MIME);
 $current_mime=$finfo->buffer($contents);
 $mime_png='image/png';//svg-edit return image/png; charset=binary 
-$mime_svg='application/xml';//svg-edit return application/xml; charset=us-ascii TODO: shoud be image/svg+xml    (http://www.w3.org/TR/SVG11/mimereg.html)
+$mime_svg='image/svg+xml';
+$mime_xml='application/xml';//hack for svg-edit because original code return application/xml; charset=us-ascii. See
+  
 if(strpos($current_mime, $mime_png)===false && $extension=='png')
 {
 	die();//File extension does not match its content
-}elseif(strpos($current_mime, $mime_svg)===false && $extension=='svg')
+}elseif(strpos($current_mime, $mime_svg)===false && strpos($current_mime, $mime_xml)===false && $extension=='svg')
 {
 	die();//File extension does not match its content
 }
 
-
 //checks if the file exists, then rename the new
 if(file_exists($saveDir.'/'.$filename.$i.'.'.$extension) && $currentTool=='document/createdraw'){
 	$i = 1;