Merge remote-tracking branch 'origin/support/2.7' into support/2.7

This commit is contained in:
bruno-ds
2021-02-18 16:29:44 +01:00
5 changed files with 34 additions and 17 deletions

View File

@@ -3256,16 +3256,15 @@ EOF
*/
public function DisplayDocumentInline(WebPage $oPage, $sAttCode)
{
/** @var \ormDocument $oDoc */
$oDoc = $this->Get($sAttCode);
$sClass = get_class($this);
$Id = $this->GetKey();
switch ($oDoc->GetMainMimeType())
{
switch ($oDoc->GetMainMimeType()) {
case 'text':
case 'html':
$data = $oDoc->GetData();
switch ($oDoc->GetMimeType())
{
switch ($oDoc->GetMimeType()) {
case 'text/xml':
$oPage->add("<iframe id='preview_$sAttCode' src=\"".utils::GetAbsoluteUrlAppRoot()."pages/ajax.render.php?operation=display_document&class=$sClass&id=$Id&field=$sAttCode\" width=\"100%\" height=\"400\">Loading...</iframe>\n");
break;

View File

@@ -2337,4 +2337,12 @@ class utils
$e = new CoreException($sMessage, null, '', $oException);
throw $e;
}
/**
* @return bool : indicate whether we run under a windows environnement or not
* @since 2.7.4 : N°3412
*/
public static function IsWindowsEnvironment(){
return (substr(PHP_OS,0,3) === 'WIN');
}
}

View File

@@ -554,19 +554,23 @@ class SetupUtils
return new CheckResult(CheckResult::ERROR, "The PHP exec() function has been disabled on this server");
}
clearstatcache();
if (!is_file($sGraphvizPath) || ! is_executable($sGraphvizPath)){
//N°3412 avoid shell injection
return new CheckResult(CheckResult::ERROR, "$sGraphvizPath could not be executed: Please make sure it is installed and in the path");
}
$sGraphvizPath = escapeshellcmd($sGraphvizPath);
// availability of dot / dot.exe
if (empty($sGraphvizPath))
{
$sGraphvizPath = 'dot';
} else {
clearstatcache();
if (!is_file($sGraphvizPath) || !is_executable($sGraphvizPath)) {
//N°3412 avoid shell injection
return new CheckResult(CheckResult::ERROR,
"$sGraphvizPath could not be executed: Please make sure it is installed and in the path");
}
if (!utils::IsWindowsEnvironment()){
$sGraphvizPath = escapeshellcmd($sGraphvizPath);
}
}
$sCommand = "\"$sGraphvizPath\" -V 2>&1";
$aOutput = array();

View File

@@ -517,7 +517,8 @@ class CriterionConversionTest extends ItopDataTestCase
*/
function testOqlToForSearchToOqlAltLanguageFR($sOQL, $sExpectedOQL, $aExpectedCriterion)
{
$this->OqlToSearchToOqlAltLanguage($sOQL, $sExpectedOQL, $aExpectedCriterion, "FR FR");
\MetaModel::GetConfig()->Set('date_and_time_format', array('default' => array('date' => 'Y-m-d', 'time' => 'H:i:s', 'date_time' => '$date $time')));
$this->OqlToSearchToOqlAltLanguage($sOQL, $sExpectedOQL, $aExpectedCriterion, "FR FR");
}
@@ -537,10 +538,10 @@ class CriterionConversionTest extends ItopDataTestCase
*/
function testOqlToForSearchToOqlAltLanguageEN($sOQL, $sExpectedOQL, $aExpectedCriterion)
{
\MetaModel::GetConfig()->Set('date_and_time_format', array('default' => array('date' => 'Y-m-d', 'time' => 'H:i:s', 'date_time' => '$date $time')));
$this->OqlToSearchToOqlAltLanguage($sOQL, $sExpectedOQL, $aExpectedCriterion, "EN US");
}
function OqlProviderDates()
{
return array(

View File

@@ -30,16 +30,16 @@ class SetupUtilsTest extends ItopTestCase
}
/**
* @dataProvider CheckGravitzProvider
* @dataProvider CheckGraphvizProvider
*/
public function testCheckGravitz($sScriptPath, $iSeverity, $sLabel){
public function testCheckGraphviz($sScriptPath, $iSeverity, $sLabel){
/** @var \CheckResult $oCheck */
$oCheck = SetupUtils::CheckGraphviz($sScriptPath);
$this->assertEquals($iSeverity, $oCheck->iSeverity);
$this->assertContains($sLabel, $oCheck->sLabel);
}
public function CheckGravitzProvider(){
public function CheckGraphvizProvider(){
if (substr(PHP_OS,0,3) === 'WIN'){
return [];
}
@@ -55,6 +55,11 @@ class SetupUtilsTest extends ItopTestCase
2,
"",
],
"empty command => dot by default" => [
"",
2,
"",
],
"command failed" => [
"/bin/ls",
1,