mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°941 - Backup/Windows %, ! or " not allowed in password
This commit is contained in:
@@ -42,7 +42,6 @@ function TestConfig($sContents, $oP)
|
||||
eval('if(0){'.trim($sSafeContent).'}');
|
||||
$sNoise = trim(ob_get_contents());
|
||||
ob_end_clean();
|
||||
CheckDBPasswordInNewConfig($sSafeContent);
|
||||
}
|
||||
catch (Error $e)
|
||||
{
|
||||
@@ -78,17 +77,17 @@ function TestConfig($sContents, $oP)
|
||||
/**
|
||||
* @param $sSafeContent
|
||||
*
|
||||
* @throws \Exception
|
||||
* @return bool
|
||||
*/
|
||||
function CheckDBPasswordInNewConfig($sSafeContent)
|
||||
function DBPasswordInNewConfigIsOk($sSafeContent)
|
||||
{
|
||||
$bIsWindows = (array_key_exists('WINDIR', $_SERVER) || array_key_exists('windir', $_SERVER));
|
||||
|
||||
if ($bIsWindows && (preg_match("@'db_pwd' => '[^%!\"]+',@U", $sSafeContent) === 0))
|
||||
{
|
||||
// Unsupported Password
|
||||
throw new Exception("On Windows, database password must not contain %, ! or \" character (backups won't work)...");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
@@ -179,7 +178,14 @@ try
|
||||
@unlink($sTmpFile);
|
||||
@chmod($sConfigFile, 0444); // Read-only
|
||||
|
||||
$oP->p('<div id="save_result" class="header_message message_ok">'.Dict::S('config-saved').'</div>');
|
||||
if (DBPasswordInNewConfigIsOk($sConfig))
|
||||
{
|
||||
$oP->p('<div id="save_result" class="header_message message_ok">'.Dict::S('config-saved').'</div>');
|
||||
}
|
||||
else
|
||||
{
|
||||
$oP->p('<div id="save_result" class="header_message message_info">'.Dict::S('config-saved-warning-db-password').'</div>');
|
||||
}
|
||||
$sOriginalConfig = str_replace("\r\n", "\n", file_get_contents($sConfigFile));
|
||||
}
|
||||
catch (Exception $e)
|
||||
|
||||
@@ -35,4 +35,5 @@ Dict::Add('EN US', 'English', 'English', array(
|
||||
'config-reverted' => 'The configuration has been reverted.',
|
||||
'config-parse-error' => 'Line %2$d: %1$s.<br/>The file has NOT been updated.',
|
||||
'config-current-line' => 'Editing line: %1$s',
|
||||
'config-saved-warning-db-password' => 'Successfully recorded, but the backup won\'t work due to unsupported characters in the database password.',
|
||||
));
|
||||
|
||||
@@ -19,4 +19,5 @@ Dict::Add('FR FR', 'French', 'Français', array(
|
||||
'config-reverted' => 'Vos modifications ont été écrasées par la version enregistrée.',
|
||||
'config-parse-error' => 'Ligne %2$d: %1$s.<br/>Le fichier n\'a PAS été modifié.',
|
||||
'config-current-line' => 'Ligne en édition : %1$s',
|
||||
'config-saved-warning-db-password' => 'Configuration enregistrée. Les sauvegardes ne fonctionneront pas à cause du format du pot de passe de la base.',
|
||||
));
|
||||
|
||||
@@ -1309,9 +1309,8 @@ EOF
|
||||
$bIsWindows = (array_key_exists('WINDIR', $_SERVER) || array_key_exists('windir', $_SERVER));
|
||||
if ($bIsWindows && (preg_match('@([%!"])@',$sDBPwd) > 0))
|
||||
{
|
||||
// Unsuported Password, disable the "Next" button
|
||||
$oPage->add_ready_script('$("#wiz_form").data("db_connection", "error");');
|
||||
$oPage->add_ready_script('$("#db_info").html("<img src=\'../images/error.png\'/> On Windows, database password must not contain %, ! or " character");');
|
||||
// Unsuported Password, warn the user
|
||||
$oPage->add_ready_script('$("#db_info").html("<img src=\'../images/error.png\'/> On Windows, the backup won\'t work because database password contains %, ! or " character");');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user