Merge with 4fe443051d53599c0d958b61dabfadbe94bc6847

skala
Ivan Tcholakov 14 years ago
commit 3067daccaa
  1. 21
      main/inc/lib/svg-edit/extensions/fileopen.php
  2. 36
      main/inc/lib/svg-edit/extensions/filesave.php

@ -22,6 +22,8 @@ if(!isset($_FILES['svg_file']['tmp_name'])) {
api_not_allowed(false);//from Chamilo
die();
}
?>
<!doctype html>
<?php
@ -42,24 +44,25 @@ if(!isset($_FILES['svg_file']['tmp_name'])) {
$prefix = 'data:' . $info['mime'] . ';base64,';
}
//a bit title security
//check the extension
$extension = explode('.', $file);
$extension = strtolower($extension[sizeof($extension) - 1]);
//a bit title security
$filename = addslashes(trim($file));
$filename = Security::remove_XSS($filename);
$filename = replace_dangerous_char($filename, 'strict');
$filename = disable_dangerous_file($filename);
$filename = disable_dangerous_file($filename);
//a bit mime security
$finfo = new finfo(FILEINFO_MIME);
$current_mime=$finfo->buffer($contents);
$current_mime = $_FILES['svg_file']['type'];
$mime_svg='image/svg+xml';
$mime_xml='application/xml';//hack for svg-edit because original code return application/xml; charset=us-ascii.
if(strpos($current_mime, $mime_svg)===false && strpos($current_mime, $mime_xml)===false && $extension=='svg'){
die();//File extension does not match its content
// die();//File extension does not match its content disabled to check into chamilo dev campus TODO:enabled
}
?>
<script>

@ -58,7 +58,7 @@ $title = Database::escape_string(str_replace('_',' ',$filename));
//get Chamilo variables
if(!isset($_SESSION['draw_dir']) ||!isset($_SESSION['whereami']) )
if(!isset($_SESSION['draw_dir']) || !isset($_SESSION['whereami']) )
{
api_not_allowed(false);//from Chamilo
die();
@ -79,18 +79,28 @@ $filename = replace_dangerous_char($filename, 'strict');
$filename = disable_dangerous_file($filename);
//a bit mime security
$finfo = new finfo(FILEINFO_MIME);
$current_mime=$finfo->buffer($contents);
$mime_png='image/png';//svg-edit return image/png; charset=binary
$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 && strpos($current_mime, $mime_xml)===false && $extension=='svg')
{
die();//File extension does not match its content
if (phpversion() >= '5.3') {
$finfo = new finfo(FILEINFO_MIME);
$current_mime=$finfo->buffer($contents);
finfo_close($finfo);
$mime_png='image/png';//svg-edit return image/png; charset=binary
$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 //disabled to check into chamilo dev campus
}elseif(strpos($current_mime, $mime_svg)===false && strpos($current_mime, $mime_xml)===false && $extension=='svg')
{
//die();//File extension does not match its content //disabled to check into chamilo dev campus TODO:enabled
}
}else{
if($suffix!= 'svg' || $suffix!= 'png')
{
//die();//disabled to check into chamilo dev campus
}
}
//checks if the file exists, then rename the new

Loading…
Cancel
Save